Implicitly converting a newly allocated array to immutable
Ali Çehreli
acehreli at yahoo.com
Sun Jan 5 20:10:03 PST 2014
On 01/05/2014 05:19 PM, Meta wrote:> The following doesn`t work:
>
> immutable(string[]) strArr = new string[](10);
A pure function is a workaround. The return value of a pure function is
implicitly convertible to immutable:
pure string[] foo()
{
return new string[](10);
}
void main()
{
immutable(string[]) strArr = foo();
}
Ali
More information about the Digitalmars-d-learn
mailing list