Empty string: Difference between revisions

Line 2,830:
end
</syntaxhighlight>
 
=={{header|RPL}}==
===Assigning an empty string to a variable===
Here, s1 is a temporary variable that disappears at execution end: the <code>→</code> instruction both declares the variable and transfers the value at stack level 1 into it. <code>STO</code> does the same, but the syntax is different (instruction after the variable name) and the created variable is persistent.
≪ "" → s1
≪ "" 's2' STO
"something" 's3' STO
≫ ≫
===Testing if a string variable is empty===
2 methods:
IF s2 "" == THEN "Empty" END
IF s2 SIZE NOT THEN "Empty" END
===Testing if a string variable is not empty===
2 methods:
IF s3 "" ≠ THEN "Not empty" END
IF s3 SIZE THEN "Not empty" END
 
=={{header|Ruby}}==
1,150

edits