Permalink
Browse files

simplified Stack#take

  • Loading branch information...
1 parent 55b26e2 commit 96c8f8ba8d9f4edae5ed126f783de820c4eeeb7c @bakkdoor committed Sep 2, 2009
Showing with 3 additions and 6 deletions.
  1. +3 −6 runtime/datastack.rb
View
@@ -26,12 +26,9 @@ def size
end
def take(n)
- vals = []
- n.times{ |i|
- check_empty(n-i)
- vals << values.pop
- }
- vals
+ check_empty(n)
+ vals = values.slice!((values.length - n), values.length)
+ vals.reverse
end
def clear

0 comments on commit 96c8f8b

Please sign in to comment.