Skip to content

Instantly share code, notes, and snippets.

@jeremywrowe
Created October 8, 2012 16:27
Show Gist options
  • Save jeremywrowe/3853416 to your computer and use it in GitHub Desktop.
Save jeremywrowe/3853416 to your computer and use it in GitHub Desktop.
id-tap-that-3
def top_three_scores
[2,1,4,3].tap{|a| a.sort! }.tap{|a| a.reverse! }.tap{|a| a.select!{|s| s > 1}} # => [4,3,2]
end
@johannes-riecken
Copy link

Isn't that the same as without tap?
[2,1,4,3].sort!.reverse!.select!{|s| s > 1} # => [4,3,2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment