Set#=== (aliased to include?)
Set#=== as an alias for
Set#include? so that sets may be used in
require 'set' GOOD_COMMANDS = Set[ :foo, :bar, :jim ] BAD_COMMANDS = Set[ :baz, :bax, :jam ] ODD_COMMANDS = Set[ :quux, :xyzzy ] case my_command when GOOD_COMMANDS then puts "Yay!" when BAD_COMMANDS then puts "Boo!" when ODD_COMMANDS then puts "Whaa?" end
Updated by sawa (Tsuyoshi Sawada) about 4 years ago
I think that is ad hoc. Splat could be used, just like with arrays.
case my_command when *GOOD_COMMANDS then puts "Yay!" when *BAD_COMMANDS then puts "Boo!" when *ODD_COMMANDS then puts "Whaa?" end
And one-time splatting would be also more efficient than calling
include? each time.