In Python, "truthiness" is a lot more complex. For instance, [1] is true, whereas [] is false, and in general, classes can define their own notion of truthiness.

Ruby has "==", "===", ".eql", and ".equal". "===" is for case statements. "==" is related to ">=", etc. ".eql" tests that the two objects have the "same content". Usually, "==" and ".eql" return the same thing, but their implementation is different. ".equal" is reserved for object identity. Hence:

There are a couple ways to create a hash. The second syntax is a bit weird to my eyes:

>> {:a => :b}=> {:a=>:b}

>> Hash[:a => :b]=> {:a=>:b}

By default, you'll get nil if you try to lookup a key that doesn't exist in a hash. As I've mentioned before, I prefer to get exceptions by default if I misspell things. Fortunately, the fetch method exists:

See my earlier post concerning "^" vs. "\A" in regular expressions. Ruby and Python are subtly different. Whereas I would normally use "^" in Python, to get the same behavior, I would use "\A" in Ruby.

If you want to treat a string as an array of characters, use '"foobar".split(//)'.

String#scan is a pretty cool method that repeatedly tries to match a regular expression while iterating over a string. Unlike #match, it returns all of the matches, instead of just the first:

>> s = "John Doe was the father of Jane Doe."=> "John Doe was the father of Jane Doe.">> s.scan(/([A-Z]\w+)\s+([A-Z]\w+)/)=> [["John", "Doe"], ["Jane", "Doe"]]