immutable ref foreach on values

bearophile bearophileHUGS at lycos.com
Fri Jun 22 05:31:24 PDT 2012


Dmitry Olshansky:

> then every array is implicitly castable to tail immutable.
> int[] array = [1, 2];
>
>     foreach (ref immutable(int) x; array) {
> 	...
> 	func(arr); // arr is mutable, thus func can change x
> 	// so x can be at most  const
>     }

I understand, thank you :-)

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list