On Tue, 2003-10-07 at 16:53, Pat Carmody wrote:
>
> On Tue, 7 Oct 2003, Curt Zirzow wrote:
>
> >> function istrue() {
> >> return true;
> >> }
> >> function retor_test() {
> >> istrue() or return( "False" );
> >> return "True";
> >> }
>
> > return (istrue()? 'True': 'False');
> >
> >hmm.. less typing, easier to understand and logically readable.
>
> This doesn't answer the problem because it does not follow the same
> logic as the orignial code example. In your example you want to return a
> value regardless of what istrue() returns. In my example I only wanted to
> return a value if istrue() failed, otherwise I wanted to continue in the
> scope of the function. That may not have been obvious because the example
> was a little contrived.
here you go:
if( 'some condition' )
{
return 'some value';
}
Simple, logical, exactly the way 99.99999% of the population would code
what you want.
Incidentally I'm beginning to notice that your method even if it worked
would not be as lazy as you claim. Contrast:
if( !istrue() ) return "False";
return "True";
versus
istrue() or return( "False" );
return "True";
Net savings: 1 character.
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php