Lasso Soft Inc. > Home

[ set->insert ]

Method

The [set->insert] method inserts the specified value into the set. The set is modified in-place and no result is returned.

  • Syntax
set->insert( value )
Examples
  • Beginner

To add elements to a set

Use the [set->insert] method. This example adds all of the elements of an array to a set.

Note: Since a set can only contain one of any given element, this is a simple method for removing duplicates from an array or map.

Code

var( days = array('Mon','Tues','Fri','Tues','Sun','Sat','Mon'),
     myDays = set )

$days->forEach => {
     $myDays->insert(#1)
}

$myDays

Result

set(Fri, Mon, Sat, Sun, Tues)

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