Module: InEnumerable

Included in:
Object
Defined in:
lib/in_enumerable.rb

Overview

Extends the Object type with the tasty ‘in?’ method, which tells you if an object is included in an Array or other enumerable value

Instance Method Summary collapse

Instance Method Details

#in?(enumerable) ⇒ Boolean

Returns true if enumerable includes self. Like this:

1.in? [1,2]          # => true
3.in? [1,2]          # => false

Parameters

enumerable

Any value that implements an include? method. E.g., Array, Hash, String, Range.

Returns:

  • (Boolean)


11
12
13
# File 'lib/in_enumerable.rb', line 11

def in?(enumerable)
  enumerable.include? self
end