Empty string: Difference between revisions

(add Mercury)
Line 525:
//or
if !str.isEmpty() { }</lang>
 
=={{header|Caché ObjectScript}}==
<lang Caché ObjectScript>EMPTYSTR
; Demonstrate how to assign an empty string to a variable.
set x = ""
; Demonstrate how to check that a string is empty.
; Length 0 is empty; equality/pattern check are 1=T, 0=F
write !,"Assigned x to null value. Tests: "
write !,"String length: "_$length(x)_", Equals null: "_(x = "")_", Empty pattern: "_(x?."") ; length 0 is empty
; Demonstrate how to check that a string is not empty. Same as above.
set x = " " ;assign to a space - not null
write !!,"Assigned x to a single blank space. Tests: "
write !,"String length: "_$length(x)_", Equals null: "_(x = "")_", Empty pattern: "_(x?."")
quit</lang>
 
{{out}}SAMPLES>do EMPTYSTR^ROSETTA
 
Assigned x to null value. Tests:
String length: 0, Equals null: 1, Empty pattern?: 1
 
Assigned x to a single blank space. Tests:
String length: 1, Equals null: 0, Empty pattern?: 0
 
 
=={{header|Clojure}}==
Anonymous user