Lasso Soft Inc. > Home

[ set->get ]

Method

[set->get(key)] returns an element of the set. Since sets exist entirely of keys, the key is provided and the key is returned if it is contained within the set. If the key does not exist within the set, a failure is generated.

  • Syntax
set->get( test_value )
Examples
  • Beginner

Verify that a given element is in a set.

Use the [set->get] method. This example uses the [set->get] method to check a set for the presence of elements of an array.

Code

var( theWeek = set('Mon','Tue','Wed','Thu','Fri','Sat','Sun'),
     myDays = array('Tue', 'Sat', '4th', 'Sun') )

with d in $myDays
     do => {^
          protect => {^
                'My day '+ $theWeek->get(#d) +' is in the week\n'
          ^}
     ^} 

Result

My day Tue is in the week
My day Sat is in the week
My day Sun is in the week
Resources
  • Tips

This method differs greatly from its Lasso 8.x counterpart the [set->get] tag which returned the element of a set found at a given position. Since the elements of Lasso9 set objects are unordered this functionality is not available.

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