Skip to content

Instantly share code, notes, and snippets.

@brianstorti
Created May 29, 2011 17:19
Show Gist options
  • Save brianstorti/997963 to your computer and use it in GitHub Desktop.
Save brianstorti/997963 to your computer and use it in GitHub Desktop.
Ruby - select x reject x collect
a = [1,2,3,4]
a.select{|n| n > 2} # 3,4
a.reject{|n| n > 2} # 1,2
a.collect{|n| n * 2} # 2,4,6,8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment