probably asked already but I couldn\'t find it.. here are 2 common situation (for me while programming rails..) that are frustrating to write in ruby:
\"a string
"a string"[/abc(.+)abc/, 1]
# => nil
"abc123abc"[/abc(.+)abc/, 1]
# => "123"
And:
var = something.very.long.and.tedious.to.write || something.other
Please note that or
has a different operator precedence than ||
and ||
should be preferred for this kind of usage. The or
operator is for flow control usage, such as ARGV[0] or abort('Missing parameter')
.