Empty string: Difference between revisions
Content deleted Content added
Added Bracmat |
|||
Line 6: | Line 6: | ||
* Demonstrate how to assign an empty string to a variable. |
* 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 empty. |
||
* Demonstrate how to check that a string is not empty. |
* Demonstrate how to check that a string is not empty. |
||
Line 52: | Line 53: | ||
If (var != "") |
If (var != "") |
||
Msgbox the var is not empty</lang> |
Msgbox the var is not empty</lang> |
||
=={{header|Bracmat}}== |
|||
There are two ways to assign a string to a variable. The variant using the <code>=</code> operator does not evaluate the value before the assignment, the variant using the <code>:</code> (match) operator does. If the value is a string, there is no difference, as a string always evaluates to itself. |
|||
<lang bracmat>( :?a |
|||
& (b=) |
|||
& abra:?c |
|||
& (d=cadabra) |
|||
& !a: { a is empty string } |
|||
& !b: { b is also empty string } |
|||
& !c:~ { c is not an empty string } |
|||
& !d:~ { neither is d an empty string } |
|||
) |
|||
</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |