Skip to content

Instantly share code, notes, and snippets.

@kinduff
Created July 29, 2015 18:09
Show Gist options
  • Save kinduff/0fda2d829551d0e9361b to your computer and use it in GitHub Desktop.
Save kinduff/0fda2d829551d0e9361b to your computer and use it in GitHub Desktop.
def findIndex(values, target)
values.each_with_index do |value, i|
return i if value == target
end
end
findIndex([4, 8, 15, 16, 23, 42], 15)
# => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment