RosettaCodeData/Task/Search-a-list/Ruby/search-a-list-1.rb
2015-11-18 06:14:39 +00:00

9 lines
224 B
Ruby

haystack = %w(Zig Zag Wally Ronald Bush Krusty Charlie Bush Bozo)
%w(Bush Washington).each do |needle|
if (i = haystack.index(needle))
puts "#{i} #{needle}"
else
raise "#{needle} is not in haystack\n"
end
end