Array literals MUST be immutable.

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 18 06:09:56 PST 2010


On Thu, 18 Feb 2010 08:00:55 -0500, Don <nospam at nospam.com> wrote:

> Including the library implementation:
>
> T[] toArray(T)(T[] values...)
> {
>      return values.dup;
> }
>
> int[] array = toArray(x,y,z);
>
> Mutable array literals achieve almost nothing.
>

I don't think this will work:

toArray(1, 2L, 3.0)

I'm not saying that this is a reason not to consider the change, but it  
does note a difference.  You can always simply do toArray!double(...) to  
get around the limitation.

-Steve



More information about the Digitalmars-d mailing list