RosettaCodeData/Task/Search-a-list/E/search-a-list.e
Ingy döt Net 764da6cbbb CDE
2013-04-10 16:57:12 -07:00

12 lines
364 B
Text

def haystack := ["Zig","Zag","Wally","Ronald","Bush","Krusty","Charlie","Bush","Bozo"]
/** meet the 'raise an exception' requirement */
def find(needle) {
switch (haystack.indexOf1(needle)) {
match ==(-1) { throw("an exception") }
match index { return index }
}
}
println(find("Ronald")) # prints 3
println(find("McDonald")) # will throw