Re: Re: PHP Brain Teasers

From: Date: Wed, 27 Jun 2007 14:57:42 +0000
Subject: Re: Re: PHP Brain Teasers
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-257874@lists.php.net to get a copy of this message
Jay Blanchard wrote:
[snip]
[snip]
<?php function think($i) { TRUE == $i ? 'self-aware' : 'cow'; $return($i);
$return($i); ?? You sure about that one? [/snip] *applause* We have a thinker here ladies and gentlemen! OK Stut, for
the
$10,000 bonus....what should you return here and what is the least amount of code you can do it in?
I'm not sure here, but are you being sarcastic? ;) Ignoring the extra $ and moving on... I would code it like this... function think(&$i) {
     $i = 'am';
} If I call think, then I am thinking, therefore $i should become 'am'. If you return 'am' rather than changing $i IMHO you're deviating from the spec. [/snip] No sarcasm at all. And you are spot on!
Or how about a very dangerous OOP version... class I {
    public function think()
    {
        $this = 'am';
    }
} -Stut -- http://stut.net/

« previous php.general (#257874) next »