On 5/28/18 9:51 AM, James Blachly wrote:
Why are the class objects special in this case, and why does
`immutable(C)[]` not help? I believed that this defined a dynamic
array `c` which was itself mutable, the elements of which were immutable.
To build on what others have said, the key thing
On Monday, 28 May 2018 at 13:51:49 UTC, James Blachly wrote:
Consider the below:
```
class C
{
int x;
}
struct S
{
int x;
}
void main()
{
immutable C[] c = [ new C(), new C()];
immutable S[] s = [ S(), S() ];
immutable int[] i = [ 1, 2 ];
auto x = c.dup;
On Monday, May 28, 2018 13:51:49 James Blachly via Digitalmars-d-learn
wrote:
> Consider the below:
>
> ```
> class C
> {
> int x;
> }
>
> struct S
> {
> int x;
> }
>
>
> void main()
> {
> immutable C[] c = [ new C(), new C()];
> immutable S[] s = [ S(), S() ];
> immutable
Consider the below:
```
class C
{
int x;
}
struct S
{
int x;
}
void main()
{
immutable C[] c = [ new C(), new C()];
immutable S[] s = [ S(), S() ];
immutable int[] i = [ 1, 2 ];
auto x = c.dup;
auto y = s.dup;
auto z = i.dup;
}
```
This fails to