This version is out of date, covering development from v5.0.0 to v5.12.2. It is maintained here only for inbound reference links from elsewhere.

Jump to the current version of aTbRef.

Tinderbox Icon

Chaining 'dot' functions

Where pertinent, the 'dot' functions (operators prefaced with a period), like .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

"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 fro lists/sets and some only for string even though others cover both types of data.

It is possible to chain to parentheses:

(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.


Possible relevant notes (via "Similar Notes" feature):


A Tinderbox Reference File : Actions & Rules : Chaining 'dot' functions