[Ruby] unless block on one line

shaners becker veganstraightedge at gmail.com
Fri Jan 26 06:32:38 PST 2007


is there a way of expressing this on one line?

unless row.at(7).nil?
   this_row[:print_date] = row.at(7).date
end

i thought it would be

unless row.at(7).nil? this_row[:print_date] = row.at(7).date end

or maybe

unless row.at(7).nil? {this_row[:print_date] = row.at(7).date}

i always hear/see people being uber succinct in ruby and i get stuck  
on these blocks that feel like they could probably be on one line.

thanks
shaners

-----------
join the resistance. fall in love.
http://theresistancearmy.com/




More information about the Ruby mailing list