Lasso Soft Inc. > Home

[ pair->get ]

Method

The [pair->get] returns either the first or second element of a pair. Setting the parameter to 1 is equivalent to using [pair->first] while setting the parameter to 2 is equivalent to the [pair->second] method. Passing any integer other than 1 or 2 to this method returns a "Position out of range" error.

The [pair->get] and [pair->size] methods ensure that the [iterate] method functions on pairs as well as on maps, arrays, and strings.

  • Syntax
pair->get(1)

pair->get(2)
Examples
  • Beginner

To get each element of a pair:

Use the [pair->get] method. Since the size of a pair is always 2 this tag only works with an index of 1 or 2. The following example loops through the elements of a pair using the [pair-size] method (which returns 2) and outputs them using the [pair->get] method.

Code

var( myPair = pair('first', 'second') )

loop($myPair->size) => {^
     'Element '+loop_count+' is '+$myPair->get(loop_count)+'\n'
^}

Result

Element 1 is first
Element 2 is second

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft