Skip to content

Instantly share code, notes, and snippets.

@blake41
Created July 27, 2015 18:12
Show Gist options
  • Save blake41/9f7c392a9f8bd566e66a to your computer and use it in GitHub Desktop.
Save blake41/9f7c392a9f8bd566e66a to your computer and use it in GitHub Desktop.
myhash = {:blake => 10, :katie => 10, :steven => 11}
container = []
myhash.each do |name, value|
container << name if value == 10
end
container
# in a method
def find_keys_with_value(value_to_find)
myhash = {:blake => 10, :katie => 10, :steven => 11}
container = []
myhash.each do |name, value|
container << name if value == value_to_find
end
container
end
find_keys_with_value(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment