List.Contains() Or Something Similar?

Monkey Forums/Monkey Programming/List.Contains() Or Something Similar?

c.k.(Posted 2012) [#1]
I know string lets us do a find/match with MyString.Contains(). Does List have something similar, or do I have to loop through it to find if something exists.

[monkeycode]
Local myList:IntList = [ 0, 1, 2, 4, 8, 16 ]
Print myList.Find[ 7 ]
Print myList.Find[ 8 ]

' prints
' -1 - not found in list (or 0, as was not found)
' 4 - as element of list myList[4] = 8 (or 5, as 5th element of list)
[/monkeycode]

I looked! Honest!


muddy_shoes(Posted 2012) [#2]
list.monkey has this method:

Method Contains?( value:T )

You're better off looking at the code than trusting the documentation to be up-to-date or accurate.


c.k.(Posted 2012) [#3]
Thanks, muddy. I'm not used to bad docs. XD

Oops. What about Array? :-/


Shinkiro1(Posted 2012) [#4]
Well, you could look at the code as muddy shoes suggested :)
In modules/monkey/lang.monkey the array class seems not to have a Contains Method.