"Sputnik" help  
Sputnik Help
Language Reference - Operators - Operator x (Repetition)

Operator x

Repetition. e.g.

// Using on a string to duplicate the string many times
my $value = "Test" x 10;
printr $value;
// PRINTS
// TestTestTestTestTestTestTestTestTestTest
 
// Using on an array to duplicate the array many times
my $value = array("Cat", "Dog") x 10;
printr $value;
// PRINTS
// Array
// (
//     [0] => Cat
//     [1] => Dog
//     [2] => Cat
//     [3] => Dog
//     [4] => Cat
//     [5] => Dog
//     [6] => Cat
//     [7] => Dog
//     [8] => Cat
//     [9] => Dog
//     [10] => Cat
//     [11] => Dog
//     [12] => Cat
//     [13] => Dog
//     [14] => Cat
//     [15] => Dog
//     [16] => Cat
//     [17] => Dog
//     [18] => Cat
//     [19] => Dog
// )
 
// Can also do stuff like
(say("CAT")) x 3;
// PRINTS
// CAT
// CAT
// CAT

Can also be used on arrays like:

my $a = array("One", "Two") x 2;
printr $a;
// PRINTS
// Array
// (
//     [0] => One
//     [1] => Two
//     [2] => One
//     [3] => Two
// )

It can be used on functions that return an array like:

Function ArrRet()
{
    return array("One", "Two");
}
my $a = ArrRet() x 2;
printr $a;
// PRINTS
// Array
// (
//     [0] => One
//     [1] => Two
//     [2] => One
//     [3] => Two
// )

To see a list of all the operators go here.


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