WingedKnight has asked for the wisdom of the Perl Monks concerning the following question:
Ran into a strange interaction between print and the ternary conditional operator that I don't understand. If we do...:
print 'foo, ' . (1 ? 'yes' : 'no') . ' bar';
...then we get the output...:
foo, yes bar
...as we would expect. However, if we do...:
print (1 ? 'yes' : 'no') . ' bar';
...then we just get the output...:
yes
Why isn't " bar" getting appended to the output in the second case?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange interaction between print and the ternary conditional operator
by kcott (Archbishop) on Feb 20, 2020 at 07:22 UTC | |
|
Re: Strange interaction between print and the ternary conditional operator
by tybalt89 (Monsignor) on Feb 20, 2020 at 03:39 UTC | |
|
Re: Strange interaction between print and the ternary conditional operator
by jwkrahn (Abbot) on Feb 20, 2020 at 07:20 UTC | |
|
Re: Strange interaction between print and the ternary conditional operator
by davido (Cardinal) on Feb 20, 2020 at 16:13 UTC | |
|
Re: Strange interaction between print and the ternary conditional operator
by Anonymous Monk on Feb 20, 2020 at 03:27 UTC | |
|
Re: Strange interaction between print and the ternary conditional operator
by WingedKnight (Novice) on Feb 21, 2020 at 07:02 UTC |