map question

forkit forkit at gmail.com
Sat Jan 22 19:32:07 UTC 2022


trying to make sense of the below:


// ---
module test;

import std;

void main()
{
     auto rnd = Random(unpredictableSeed);

     int howManyTimes = 5;

     // ok - using 'e =>' makes sense
     writeln(howManyTimes.iota.map!(e => rnd.dice(0.6, 
1.4)).format!"%(%s,%)");

     // ok - though using 'howManyTimes =>' doesn't make much 
sense??
     writeln(howManyTimes.iota.map!(howManyTimes => rnd.dice(0.6, 
1.4)).format!"%(%s,%)");

     // NOT ok - using '5 =>' - but isn't this effectively the 
same as above line?
     //writeln(howManyTimes.iota.map!(5 => rnd.dice(0.6, 
1.4)).format!"%(%s,%)");
}

// ---


More information about the Digitalmars-d-learn mailing list