updating oE ensure_in_list


include math.e 
namespace math 
public function ensure_in_list(object item, sequence list, integer default = 1) 

ensures that the item is in a list of values supplied by list.

  1. item : The object to test for.
  2. list : A sequence of elements that item should be a member of.
  3. default : an integer, the index of the list item to return if item is not found. Defaults to 1.

An object, if item is not in the list, it returns the list item of index default, otherwise it returns item.


If default is set to an invalid index, the first item on the list is returned instead when item is not on the list.

Example 1:
object valid_data = ensure_in_list(user_data, {100, 45, 2, 75, 121}) 
if not equal(valid_data, user_data) then 
    errmsg("Invalid input supplied. Using %d instead.", valid_data) 
end if 
Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu