On Thursday, 14 June 2012 at 23:57:36 UTC, Roman D. Boiko wrote:
immutable struct Node{ string s; }
Node[] f()
{
  Node[] arr = ...?
  return arr;
}

How to fill an array, if its elements are immutable? I want to assign values calculated by some function.

More specifically, given

auto names = ["ab", "c", "def"] ~ getMoreNames();

retrieve

[Node("ab"), Node("abc"), Node("abcdef"), ...]

where Node is an immutable struct created dynamically, possibly with usage of some accumulating variable (in this case, a string concatenating previous values).

But an answer to the first question should be enough, this example is just for clarity.

Reply via email to