Project

General

Profile

Actions

Feature #12047

closed

Set#=== (aliased to include?)

Added by Phrogz (Gavin Kistner) about 8 years ago. Updated about 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:73657]

Description

Add Set#=== as an alias for Set#include? so that sets may be used in case statements:

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
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0