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
Post a Comment