Skip to content

Commit

Permalink
modify core method that return Enumerator object if not block given
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Mar 14, 2014
1 parent 29964cf commit bc63518
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mrblib/array.rb
Expand Up @@ -31,6 +31,8 @@ def each(&block)
#
# ISO 15.2.12.5.11
def each_index(&block)
return to_enum :each_index unless block_given?

idx = 0
while(idx < length)
block.call(idx)
Expand All @@ -46,6 +48,8 @@ def each_index(&block)
#
# ISO 15.2.12.5.7
def collect!(&block)
return to_enum :collect! unless block_given?

self.each_index{|idx|
self[idx] = block.call(self[idx])
}
Expand Down

0 comments on commit bc63518

Please sign in to comment.