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

Operator ++

Increase assignment. e.g.

$var++; // adds 1 to $var -- Returns x, then increments x by one
++$var; // adds 1 to $var -- Increments 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 11

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

It can also go infinity like:

$var++++++; // adds 5 to $var
++++++$var; // adds 5 to $var

You can use ++ on strings so that:

my $var = "AB";
$var++;
say $var;
// PRINTS
// AC

my $var = "AZ";
$var++;
say $var;
// PRINTS
// BA

my $var = "999";
$var++;
say $var;
// PRINTS
// 1000

my $var = "A999";
$var++;
say $var;
// PRINTS
// B000

Another ++ on strings example:

my $var1 = "Cat0";
$var1++;
say $var1;
// PRINTS
// Cat1

my $var2 = "Cat80";
$var2++;
say $var2;
// PRINTS
// Cat81

my $var3 = "Cat80z";
$var3++;
say $var3;
// PRINTS
// Cat81a

my $var4 = "Cat80a";
$var4++;
say $var4;
// PRINTS
// Cat80b

my $var5 = "1";
$var5++;
say $var5;
// PRINTS
// 2

my $var6 = "0";
$var6++;
say $var6;
// PRINTS
// 1

my $var7 = "z";
$var7++;
say $var7;
// PRINTS
// aa

my $var8 = "b";
$var8++;
say $var8;
// PRINTS
// c

my $var9 = "a";
$var9++;
say $var9;
// PRINTS
// b

my $var10 = "000";
$var10++;
say $var10;
// PRINTS
// 001

my $var11 = "aaa";
$var11++;
say $var11;
// PRINTS
// aab

my $var12 = "bbbbbb";
$var12++;
say $var12;
// PRINTS
// bbbbbc

my $var13 = "11111";
$var13++;
say $var13;
// PRINTS
// 11112

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

To see a list of all the operators go here.


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