Enumerable Quiz


Enumerable methods can be used on which of the following objects?

Strings Arrays Hashes Ranges Integers

Which of the following are Enumerable methods?

#any? #select #include? #count #reject #map
(1..100).select{ |n| n.odd? }

The above expression generates what?

A range from 1 - 100, but only the even numbers An array from 1 - 100, but only the odd numbers A range from 1 - 50, inclusive An array from 1 - 50
words = ["primate", "marsupial", "rodent", "lemur"]
words.count{ |word| word.include?("i") }

The count method above returns what kind of object?

Integer Array String true or false

What method would you use to find the shortest word in an array of words?

sort min min_by find words.min_by { |word| word.length }

results matching ""

    No results matching ""