Jump to content

Empty string: Difference between revisions

→‎{{header|Go}}: mention Go zero value initialization; show len(s)
(added Elixir)
(→‎{{header|Go}}: mention Go zero value initialization; show len(s))
Line 460:
 
=={{header|Go}}==
Go has no special syntax for empty strings.
In Go variables are always initialized to a provided value or to the "zero value" of the type.
<lang go>// assign empty string to a variable
The zero value of a string is the empty string.
<lang go>// define and initialize an empty string
var s string
s2 := ""
 
<lang go>// assign an empty string to a variable
s = ""
 
// check that a string is empty, any of:
s == ""
len(s) == 0
 
// check that a string is not empty, any of:
s >!= ""</lang>
len(s) != 0 // or > 0</lang>
 
=={{header|Groovy}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.