Empty string: Difference between revisions

Content added Content deleted
(added Elixir)
(→‎{{header|Go}}: mention Go zero value initialization; show len(s))
Line 460: Line 460:


=={{header|Go}}==
=={{header|Go}}==
Go has no special syntax for empty strings
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 := ""

// assign an empty string to a variable
s = ""
s = ""


// check that string is empty
// check that a string is empty, any of:
s == ""
s == ""
len(s) == 0


// check that string is not empty
// check that a string is not empty, any of:
s > ""</lang>
s != ""
len(s) != 0 // or > 0</lang>


=={{header|Groovy}}==
=={{header|Groovy}}==