Re: How do I get the value cache()?

2018-01-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 January 2018 at 02:54:16 UTC, Marc wrote: let's assume I have class C { static string foo() { writeln("got called!"); // } } then I want to cache foo at some point: import std.algorithm; auto v = cache(c.foo); That doesn't do what I think you think it does. http://dpl

How do I get the value cache()?

2018-01-14 Thread Marc via Digitalmars-d-learn
let's assume I have class C { static string foo() { writeln("got called!"); // } } then I want to cache foo at some point: import std.algorithm; auto v = cache(c.foo); I call do: for(int i = 0; i <10; i++) { writeln(v); } then it'll print "got called" only once, which is what I