Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Enumerable#entries

enum.entries(*args) → array

Alias of #to_a

Returns an array containing the items in enum.

Example
(1..7).to_a                       #=> [1, 2, 3, 4, 5, 6, 7]
{ 'a'=>1, 'b'=>2, 'c'=>3 }.to_a   #=> [["a", 1], ["b", 2], ["c", 3]]

require 'prime'
Prime.entries 10                  #=> [2, 3, 5, 7]
See also #to_a #each_with_object #filter #each_with_index also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1