This is a fairly basic Ruby thing, but it was new to me, and it might pique some interest among all the non-Ruby-loving heathen out there. Seriously guys, how can you not love this language already?
Did you know that in Ruby, you can use if/else anywhere you could use the ternary (?:), with no other changes? Every block returns (by default) the value of its last statement; the overall if returns the value of the successful block. Returning different values based on a condition is effectively the behavior of the ternary.
Gape in awe at something you cannot do in C-based languages.
var = if(1 == 2) then "a" else "b" end
This is identical to var = (1 == 2) ? "a" : "b";
Unfortunately, you cannot do something like this:
(true) ? (something; something; something;) : something else;
Using parentheses around compound statements, it will not group correctly, and just get a bit confused. Using braces, it will treat the contents as a hash literal (which a pretty cool thing to do, though). do/end generates a compile error.
In conclusion, the ternary is a limited special case of if/else, providing a nicer way to write code using a conditional to produce a value. You can use if/else anywhere you’d use a ternary, but not vice versa.