Skip to content

Commit

Permalink
Prettier Array#rotate
Browse files Browse the repository at this point in the history
tap may not be supported in older ruby versions, but it's way nicer
this way! Anyway, self was useless here.
  • Loading branch information
madx committed Feb 9, 2010
1 parent 9fdf964 commit 444b975
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/core_ext.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Array
def rotate
self.push(r = self.shift)
return r
shift.tap {|e| push e }
end
end
end

0 comments on commit 444b975

Please sign in to comment.