"Sputnik" help  
Sputnik Help
Language Reference - Operators - Operator || (Logical Or Operation)

Operator ||

Logical OR operation. e.g.

my $x = 10;
my $y = 20;
if ($x || $y) // If $x is true, return $x, else return $y.
{
    say "true";
}
else
{
    say "false";
}
// PRINTS
// true

// Here is how it works
say $x || $y;
// PRINTS
// 10

In other words if either are TRUE the if will accept the statement as TRUE otherwise it wont.

Here is a cool trick to use || for:

my $black = 0x000000;
my $colours = array(
    "azure"       => 0xF0FFFF,
    "chartreuse"  => 0x7FFF00,
    "lavender"    => 0xE6E6FA,
    "magenta"     => 0xFF00FF,
    "turquoise"   => 0x40E0D0
);
say $colours["white"] || $black;
say $colours["white"] || 777;
// PRINTS
// 0
// 777

Notice when the element does not exist in the array it returns the element to the right? This is a simple way of either returning the item you wanted or a default.

To see a list of all the operators go here.


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org