If I want a part of an array I can use []
or split
:
arr = [1,2,3,4,5]
arr[1..3]
=> [2, 3, 4]
But is there a 'general' version of []
? Can I apply it to any Enumerator
?
enum = arr.each
enum.xxx_method(1..3) # is equal to arr[1..3].each
Of course you can use arr[1..3]
directly. But I'm seeking a general way to handle any enumerator.