String class

The class is designed for working with strings. String is considered defined (def), if it isn't empty. If string contains a number, the content of the string will be automatically converted to double, when used in a mathematical expression. If the string is empty, its numerical "value" in mathematical expressions will be regarded as zero.

Creating object of class
string:
$str[content of the string]

For compatibility with an empty hash, the empty and whitespace strings allows access to arbitrary fields ($str.key) without an error message.   [3.4.5]
Below is a sample code where it's convenient:

^method[
   ^if($condition1){ $.option1[
value1] }
   ^if($condition2){ $.option2[
value2] }
]

@method[options]
^if(def $options.option1){
 code }

If both conditions are false, then the options will not be a hash, but a string of whitespace characters. Nevertheless, because of the compatibility with the empty hash, the code will work as intended.



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 26.04.2017