What is the purpose of the Enumerator class in Ruby

前端 未结 5 775
我在风中等你
我在风中等你 2021-01-02 23:23

If I create an Enumertor like so:

enum = [1,2,3].each => # 

enum is an Enumerator. What

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-03 00:15

    It is possible to combine enumerators:

    array.each.with_index { |el, idx| ... }
    

提交回复
热议问题