The following conditional syntax displays the string 'is true' in irb without using
irb(main):001:0> if true
irb(main):002:1> 'is true'
irb(main):004:1* 'is false'
=> "is true"
# Odd behaviour:
puts "Why do only two of the three conditionals print?"
# This doesn't put anything to screen:
puts "Seriously, why? Or better yet: how?"
# But this does:
puts 'is true_2'
puts 'is false'
# And this works without "puts":
if 1.send(:==, 1)
"Why do only two of the three conditionals print?
Seriously, why? Or better yet: how?
The IRB output here is showing the return value of the operation, which is not necessarily what is printed to STDOUT (i.e. the terminal) during execution.
Your script is just throwing the return value away, you would have to do this:
val = if true 'is true_1' else 'is false' end puts val