On Thursday, 26 December 2013 at 11:03:17 UTC, Dfr wrote:
It is ok, but i don't want calculate 'b' every time 'come_func' is called,so i'd like to do something like this:int some_func() { if(b is null) { b = a.map!(...).assocArray; } .... }
It might not be entirely appropriate for this situation and the module constructor is perhaps the way to go but take a look at this:
http://dlang.org/phobos/std_functional.html#.memoize It allows a function to cache calculated values. It's pretty neat!
