diff options
Diffstat (limited to 'code')
-rw-r--r-- | code/extensions/basic.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/code/extensions/basic.rb b/code/extensions/basic.rb index b04dc71d..5244a459 100644 --- a/code/extensions/basic.rb +++ b/code/extensions/basic.rb @@ -14,7 +14,11 @@ end class Array def wrap(n) # TODO: this can be done better... - n.times { push shift } + if n >= 0 + n.times { push shift } + else + n.abs.times { unshift pop } + end end def cdr(n = 1) self[n .. -1] |