Gems of Python
eflorenzano.com
eflorenzano.com
1. ["1", "2", "asdf", "3"].reject {|x| begin; Integer(x); rescue; false; else; true} => ["1", "2", "3"]
2. [[1,2,3], [4,5,6]].flatten.sum => 21
3. tbl = Hash.new {|d, k| d[k] = []}
4. tbl["foo"] << 1 => ["foo"]
5. ["a", "b", "c"].zip([1,2,3]) => [["a", 1], ["b", 2], ["c", 3]]
6. "the little green men".titleize => "The Little Green Men"
Obligatory snarky aside: these aren't hidden gems in Ruby (well, except for String#titleize, which is an activesupport extension, so only Rails devs see it by default). They're baked in.