[Bioperl-l] $id && $self->display($id)

Mike Schuh schuh at farmdale.com
Thu Mar 31 16:14:24 EST 2005


Sally,

>I wonder what does it means in the following
>statement?
>
>$id && $self->display($id)

Pretty standard Perl construct.  The value of $id is checked and if it is 
"true" (defined and not zero), then the display method of the current 
object is called.

This is shorthand for

 if(defined($id) && $id) {	# to be slightly pedantic
   $self->display($id);
 }

Similar patterns are used in shell scripts, etc.

--
Mike Schuh -- Seattle, Washington USA
http://www.farmdale.com



More information about the Bioperl-l mailing list