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 -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -