I have four sizes, each are in a hash by their square feet:
# The sizes. Sizes are in sq ft (min, max)
size_hash = {
'Large' => [70,139],
'Medium' => [15,69],
'Small' => [1,14]
}
If I’m given the number 40, how can I return Medium as the size from the array?
Do I need to do something like this?:
# The sizes. Sizes are in sq ft (min, max)
size_hash = {
[70..139] => 'Large',
#... etc
}
You could use a proc: