range foreach lambda

ddos via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 17 05:20:11 PDT 2014


for example i have an array

int[] a = [1,2,3,4,5];

and a function

auto twice  = function (int x) => x * 2;

how can i apply the function to each element in a without using a 
forloop? - is there a function to do this?

a.foreach(x => x * 2);
a == [2,4,6,8,10]



More information about the Digitalmars-d-learn mailing list