In

The in operator globally tests whether an object is in the collection. It can work for arrays and custom objects:

var a = new [ 1 2 3 4 5 ]
print 2 in a // true 

For custom objects, the 'in' operator is the inverse of 'has' method. For example, the following two code snippets are identical:
var a = 1..10
print 5 in a // true

print a.has 5 // the same 

The 'in' operator will work for range and dict built-in types as well as any custom types for which the 'has' method accepting the left hand side argument type was defined.

Last edited May 6, 2011 at 7:26 PM by impworks, version 1

Comments

No comments yet.