Operator Type:
Operator Scope of Action:
Operator Purpose:
Operator First Added:
Operator Last Altered:
Function [other Function type actions]
Item [operators of similar scope]
Data manipulation [other Data manipulation operators]
Baseline
As at baseline
Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses
List/Set.asString()
List/Set.asString
The dot-operator .asString(), converts sets and lists to a string representation. This addresses an issue where much-used operators .contains() and .icontains() behave differently for Strings (where it searches for a regular expression match) compared to Lists and Sets (where it tests for set membership). Occasionally, is desirable to perform a regular expression test on a list or set—for example, to ask if any of the members of $MyList begin with the letter "a":
$MyBoolean = $MyList.asString().contains(^ a");
Note there are no arguments for this operator so the trailing parentheses optionally may be omitted:
$MyBoolean = $MyList.asString.contains(^ a");
The role of .asString() is simple:
$MyList = [winken;blinken;nod];
$MyString = $MyList.asString();
The value of MyString is now "winken;blinken;nod", still the literal stored value of my list complete with semicolon delimiters, but—importantly—Tinderbox now treats this is a literal String, despite the semicolons, and not as List/Set type data. That allows the .contains() example above to do a regex (String behaviour) match on what is otherwise treated as a 3-item list.