Skip to content
Permalink
Browse files

Merge pull request #565 from kostya/fetch

array#fetch
  • Loading branch information
alex committed Mar 31, 2013
2 parents 9624e18 + c57b656 commit b4dc5149a2ffd38dad0e14b2a13115e1cc89a498
Showing with 11 additions and 9 deletions.
  1. +11 −0 lib-topaz/array.rb
  2. +0 −9 spec/tags/core/array/fetch_tags.txt
@@ -58,6 +58,17 @@ def at(idx)
self[idx]
end

def fetch(*args, &block)
i = Topaz.convert_type(args[0], Fixnum, :to_int)
if i < -self.length || i >= self.length
return block.call(args[0]) if block
return args[1] if args.size > 1
raise IndexError.new("index #{i} outside of array bounds: -#{self.length}...#{self.length}")
else
self[i]
end
end

def each(&block)
return self.enum_for(:each) unless block
i = 0

This file was deleted.

0 comments on commit b4dc514

Please sign in to comment.
You can’t perform that action at this time.