Tinderbox v9 Icon

Chaining 'dot' operators

Where pertinent, 'dot' operators (operators prefaced with a period—see listing), like String.split(), can be chained together. If an operator's parentheses are normally optional, they be omitted if that operator has another operator chained to its right. Thus:

$MyList.sort().reverse() GOOD

$MyList.sort().reverse GOOD

$MyList.sort.reverse() GOOD

$MyList.sort.reverse GOOD

The observation "where pertinent" points to the fact that the dot operators used must act on compatible data types:

$MyList.sort().reverse() GOOD

$MyColor.red().empty() BAD

It is most likely that opportunities for chaining only occur in relation to text data functions though do be aware that some text dot operators are only for lists/sets and some only for string even though others cover both types of data.

Chaining to parentheses

It is possible to chain to parentheses and indeed is sometimes necessary. The parentheses ensure Tinderbox evaluates contents of parentheses before the dot-chained actions are applied. In this example, three strings are concatenated to a single string before its size (number of characters) is calculated:

(Hello" +" "+"world").size 

The above example is trivial but shows the general principle. In practice, the technique can become useful is the expression is complex and requires Tinderbox to fully evaluate it before processing the chained function. For instance, the links() operator already uses dot-chained arguments and so to find the number of links found using .size, it is necessary to place the whole links() expression in parentheses:

(links(children).inbound..$StartDate).size