"Sputnik" help  
Sputnik Help
Language Reference - Operators - Operator -- (Decrease Assignment)

Operator --

Decrease assignment. e.g.

$var--; // subs 1 to $var -- Returns x, then decrements x by one
--$var; // subs 1 to $var -- Decrements x by one, then returns x

The main reason to use -- before the variable is like:

// Placing ++ after the var
my $var = 10;
say $var--; // Prints 10
say $var; // Prints 9

// Placing ++ before the var
my $var = 10;
say --$var; // Prints 9
say $var; // Prints 9

It can also go infinity like:

$var------; // subs 5 to $var
------$var; // subs 5 to $var

You can use -- on strings so that:

my $var = "AB";
$var--;
say $var;
// PRINTS
// AA

my $var = "AZ";
$var--;
say $var;
// PRINTS
// AY

my $var = "CAT";
$var--;
say $var;
// PRINTS
// CAS

my $var = "CAA";
$var--;
say $var;
// PRINTS
// BZZ

my $var = "999";
$var--;
say $var;
// PRINTS
// 998

my $var = "A999";
$var--;
say $var;
// PRINTS
// A998

my $var = "A990";
$var--;
say $var;
// PRINTS
// A989

Another -- on strings example:

my $var14 = "Cat0";
$var14--;
say $var14;
// PRINTS
// Cas9

my $var15 = "Cat80";
$var15--;
say $var15;
// PRINTS
// Cat79

my $var16 = "Cat80z";
$var16--;
say $var16;
// PRINTS
// Cat80y

my $var17 = "Cat80a";
$var17--;
say $var17;
// PRINTS
// Cat79z

my $var18 = "1";
$var18--;
say $var18;
// PRINTS
// 0

my $var19 = "0";
$var19--;
say $var19;
// PRINTS
// 0

my $var20 = "z";
$var20--;
say $var20;
// PRINTS
// y

my $var21 = "b";
$var21--;
say $var21;
// PRINTS
// a

my $var22 = "a";
$var22--;
say $var22;
// PRINTS
// 0

my $var23 = "000";
$var23--;
say $var23;
// PRINTS
// 0

my $var24 = "aaa";
$var24--;
say $var24;
// PRINTS
// 0

my $var25 = "bbbbbb";
$var25--;
say $var25;
// PRINTS
// bbbba

my $var26 = "11111";
$var26--;
say $var26;
// PRINTS
// 11110

To see a list of all the operators go here.


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