Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: A Perl aptitude test

by ferrency (Deacon)
on May 02, 2003 at 17:59 UTC ( #255106=note: print w/replies, xml ) Need Help??


in reply to Re: Re: A Perl aptitude test
in thread A Perl aptitude test

You actually get a "6" followed by a "4".

print (print (2 * 3) + 3);
The inner print(2 * 3) is evaluated first: it prints 6, and returns the value "1" because the print succeeded. 1 + 3 is 4, so the outer print prints 4. There were no delimiters between the two digits, so they look like one number instead of two sequential digits.

This brings up the original trick question quite nicely: the parentheses on print (2 * 3) + 3 make print() look like a function call, they aren't simply an arithmetic grouping operator in this case.

Alan

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://255106]
help
Chatterbox?
[shmem]: J.S.Bach said: "playing Clavier is darn easy. All you have to do is to push the right key with the right finger at the right time."
[shmem]: same for programming and creating bugs.
[choroba]: programming is easy once you know how to solve the problem
[shmem]: choroba: yeah, adjusting the screw 2 - knowing which one 42

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2017-04-27 14:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (508 votes). Check out past polls.