Skip to content
instance method

Enumerable#member?

(Elem arg0) -> bool
include?(object) -> true or false

Returns whether for any element object == element:

Example
(1..4).include?(2)                       # => true
(1..4).include?(5)                       # => false
(1..4).include?('2')                     # => false
%w[a b c d].include?('b')                # => true
%w[a b c d].include?('2')                # => false
{foo: 0, bar: 1, baz: 2}.include?(:foo)  # => true
{foo: 0, bar: 1, baz: 2}.include?('foo') # => false
{foo: 0, bar: 1, baz: 2}.include?(0)     # => false
See also #max_by #min #max #min_by also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0