Skip to content

Instantly share code, notes, and snippets.

@zhhz
Created March 20, 2009 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhhz/82425 to your computer and use it in GitHub Desktop.
Save zhhz/82425 to your computer and use it in GitHub Desktop.
# DM 0.9.9
users = User.all
names = users.collect{|u| u.first_name}
names.uniq # works well, return all the names
names.uniq! # diff from MRI: return nil
# MRI
a = [1, 2, 3, 1, 2]
a.uniq #[3]
puts a #[1, 2, 3, 1, 2]
a.uniq! #[3] # diff from the DM
puts a # [3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment