Empty string: Difference between revisions

→‎{{header|Perl 6}}: Added PureBasic
(→‎{{header|Perl 6}}: Added PureBasic)
Line 119:
say 'String is empty' unless $s.chars;
say 'String is not empty' if $s.chars;</lang>
=={{header|PureBasic}}==
In PureBasic we can just test a string for truth to determine if it has a value.
<lang PureBasic>Procedure.s isStringEmpty(a.s)
If a
ProcedureReturn "String is not empty, it contains '" + a + "'."
Else
ProcedureReturn "String is empty, or null."
EndIf
EndProcedure
 
If OpenConsole()
Define a.s = ""
Define b.s = "stuff"
PrintN(isStringEmpty(a))
PrintN(isStringEmpty(b))
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()
EndIf</lang>
Sample output:
<pre>String is empty, or null.
String is not empty, it contains 'stuff'.</pre>
 
=={{header|Python}}==
Anonymous user