The Enumerable Module
Shared collection powers.
What Is Enumerable?
Enumerable is a module that gives collections like arrays, hashes, and ranges a shared set of powerful methods. Any class with each can mix it in.
puts [1, 2, 3].is_a?(Enumerable)
puts (1..3).is_a?(Enumerable)include? and member?
include? checks whether a collection contains a value.
nums = [10, 20, 30]
puts nums.include?(20)
puts (1..5).include?(3)All lessons in this course
- Creating Ranges
- The Enumerable Module
- map, select, reject
- reduce and each_with_object