One line if statement in Ruby -


i have following piece of code:

if day > 31    day -= 31    month = "april" end 

can write in 1 line different than:

if day > 31 day -= 31 , month = "april" end 

?

i've tried like:

if day > 31 {day -= 31; month = "april"}  

but doesn't work

(day -= 31; month = "april") if day > 31 

alternate way (as suggested @mudasobwa in comments below) :

day, month = day - 31, "april" if day > 31 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

qt - How to embed QML toolbar and menubar into QMainWindow -