Empty string: Difference between revisions

removed langur language example for now
m (Update Lang example: Fix spelling of Lang)
(removed langur language example for now)
 
(5 intermediate revisions by 4 users not shown)
Line 1,281:
 
Also possible is <code>(string= "" str)</code>.
 
An common lisp incompatible way:
<syntaxhighlight lang="langurlisp">val .zls = ""
(defvar str "" "An empty string")
 
(if (length= str 0)
(message "string is empty")
(message "string is not empty"))
writeln len(.zls)</syntaxhighlight>
 
=={{header|langurEMal}}==
<syntaxhighlight lang="emal">
# Demonstrate how to assign an empty string to a variable.
text sampleA = Text.EMPTY
text sampleB = "hello world"
text sampleC = ""
List samples = text[sampleA, sampleB, sampleC]
for each text sample in samples
# Demonstrate how to check that a string is empty.
writeLine("Is '" + sample + "' empty? " + when(sample.isEmpty(), "Yes", "No") + ".")
end
</syntaxhighlight>
{{out}}
0</pre>
Is '' empty? Yes.
Is 'hello world' empty? No.
Is '' empty? Yes.
</pre>true
 
=={{header|Erlang}}==
Line 1,863 ⟶ 1,891:
fn.println(parser.op(@$s > 0))
</syntaxhighlight>
 
=={{header|langur}}==
You can use empty quote marks.
<syntaxhighlight lang="langur">val .zls = ""
writeln .zls == ""
writeln .zls != ""
writeln len(.zls)</syntaxhighlight>
 
{{out}}
<pre>true
false
0</pre>
 
=={{header|Lasso}}==
Line 2,157 ⟶ 2,173:
true
false
</pre>
 
=={{header|MiniScript}}==
{{trans|Wren}}
<syntaxhighlight lang="miniscript">string.isEmpty = function
return self == ""
end function
 
number.toBoolStr = function
if self == 0 then return "false"
return "true"
end function
 
s = ""
t = "0"
print "'s' is empty? " + s.isEmpty.toBoolStr
print "'t' is empty? " + t.isEmpty.toBoolStr</syntaxhighlight>
 
{{out}}
<pre>'s' is empty? true
't' is empty? false
</pre>
 
Line 3,449 ⟶ 3,486:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var isEmpty = Fn.new { |s| s == "" }
 
var s = ""
885

edits