Ruby ternary operator structure -


puts bool ? "true" : "false" 

is proper, but

bool ? puts "true" : puts "false" 

is not. can explain me why is?

side note:

bool ? ( puts "true" ) : ( puts "false" ) 

works fine well.

when don't put parentheses on method call, ruby assumes want end of line arguments. say, these calls equivalent (and invalid):

bool ? puts "true" : puts "false" bool ? puts("true" : puts "false") 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -