Membership in a list (Set)
Using Set is probably the most convenient way to check for membership in a list since values are stored like in a Hash.
Set uses the === method to check membership, which allows:
case 'apple'
when Set['bean', 'cauliflower', 'carrot']
"vegetable"
when Set['mandarin', 'apple', 'pear']
"fruit"
end
# => "fruit"
You can also check membership directly:
'apple' === Set['mandarin', 'apple', 'pear']
# => true
'apple' === Set['bean', 'cauliflower', 'carrot']
# => false