Skip to content

Instantly share code, notes, and snippets.

@ivanacostarubio
Created January 31, 2011 20:39
Show Gist options
  • Select an option

  • Save ivanacostarubio/804762 to your computer and use it in GitHub Desktop.

Select an option

Save ivanacostarubio/804762 to your computer and use it in GitHub Desktop.
ree-1.8.7-2010.02 > ["convers","an","array","to","a","hash","clone"].to_hash_clone
=> {"a"=>"a", "an"=>"an", "hash"=>"hash", "to"=>"to", "array"=>"array", "clone"=>"clone", "convers"=>"convers"}
ree-1.8.7-2010.02 >
class Array
def to_hash_clone
inject({}){|sum, word| sum[word] = word ; sum}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment