print (1 ? 1 : 0) . 'x'
stig at brautaset.org
Thu May 11 11:11:27 BST 2006
On 11 May 2006, at 10:59, O'Shaughnessy, Jamie wrote:
> print (1 ? 1 : 0) . 'x';
> What do you expect this would print?
> I expected the output would be "1x" - the ?: evaluates to 1, the ()
> s are needed because . Is higher precedence than ?: so you end up
> with 1 . 'x' as the parameter to print - hence print "1x".
> However it doesn't, it just prints "1".
... and the return value from print is concatenated with 'x'; if you
use warnings you'd probably get a diagnostic.
The brackets are used there to delimit the function call, so it
basically boils down to:
print(1) . 'x';
More information about the london.pm