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".match(/foo(bar)/).to_a[1]
NilClass#to_a returns an empty array, and indexing outside of it gives you nil values.
NilClass#to_a
nil
Alternatively (what I do) you can splat the matches:
_, some, more = "a string".match(/foo(bar)(jim)/).to_a