Can someone explain why i can change this immutable variable please?

Gary Willoughby dev at nomad.so
Wed Oct 9 09:09:10 PDT 2013


On Wednesday, 9 October 2013 at 16:02:43 UTC, Daniel Davidson 
wrote:
> Maybe this will help explain it:
> void main() {
>   pragma(msg, typeof(Bar.name));
>   pragma(msg, typeof(Foo.change));
> }
> will print:
>
> immutable(char[][])
> void(string[] name)
>
> The latter is really:
>
> void(immutable(char)[] name)
>
> The former is really:
> immutable(immutable(immutable(char)[])[])
>
> So for name the whole kit and kaboodle is immutable and you can 
> not pass the whole immutable thing into something that is only 
> immutable at one level.
>
> Thanks
> Dan

Ah right, of course. Thanks.


More information about the Digitalmars-d-learn mailing list