Empty string: Difference between revisions

per previous discussion, removing claim about syntax for empty strings; update examples; copyedit
(added assigning an empty string)
(per previous discussion, removing claim about syntax for empty strings; update examples; copyedit)
Line 1:
{{draft task}}
 
SomeLanguages languagesmay have syntax or semanticsfeatures for dealing specifically with empty strings (those containing no characters).
 
The task is to:
 
* Demonstrate how to assign an empty string to a variable.
* Demonstrate how to check that a string is empty.
* Demonstrate how to check that a string is not empty.
 
Line 58:
 
=={{header|Icon}} and {{header|Unicon}}==
Icon and Unicon don'tcan haveproduce special syntax for nullempty strings but can produce them in several ways:
<lang Icon>s := "" # null string
s := string('A'--'A') # ... converted from cset difference
Line 156:
 
=={{header|PicoLisp}}==
The empty string is represented by '[http://software-lab.de/doc/ref.html#nilSym NIL]' in PicoLisp. During input, two subsequent double qoutesquotes '""' return the symbol NIL.
<lang PicoLisp># To assign a variable an empty string:
(off String)
Line 196:
 
=={{header|Python}}==
The empty string is printed by Python REPL as <nowiki>''</nowiki>, and is treated as boolean false, (as are most empty container types, by convention). Any non-empty ''string'', including '0', is always treated as True in a boolean context.
<lang python>s = ''
if not s: