On Wednesday, 11 April 2012 at 16:33:42 UTC, Simen Kjaeraas wrote:
On Wed, 11 Apr 2012 18:08:14 +0200, Russel Winder <[email protected]> wrote:

Doing something along the lines of:

        const a = array ( filter! ... ) ;
        foreach ( i ; a ) { ... }

works fine. Question 1 though is why I can't use immutable here, why I
have to use const.  Question 2 is why I can't do:

        const a = filter! ... ;
        foreach ( i ; a ) { ... }

The answer to #1 is easy. Nothing is implicitly castable to immutable.

Value types with no indirection are implicitly convertible to immutable.

-----------
void main()
{
    int a = 2;
    immutable int b = a;
}
-----------


Reply via email to