Chaining 'dot' functions

Tinderbox Icon

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):

Up: Actions & Rules
Previous: The 'dot' operators  Next: Stamps 

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

Quicklinks: Attributes | Action Codes | Export Codes | Designators | Date Formats | aTbRef Site Map

[Last updated: 16 May 2012, using v5.11.1]


Search:

Google search aTbRef for:  


Creative Commons Licence

aTbRef by Mark Anderson is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

[See aTbRef CC licence Attribution & Waiver info]

Made with Tinderbox