Add if not nil?
ruby, ruby-on-rails
Solution
x = y + z.to_i
`nil.to_i` will return 0, so you'll be adding nothing.
Problem
How do I write a one-liner for the following? ``` x = y + (z if != nil) ``` I tried a few different things and also searched, but can't seem to find anything that's specific to this. I tried: ``` x = y + z? z : 0 ``` but that didn't work (syntax?) and even if it did, it feels sloppy.