foreach and filter
Jakob Ovrum
jakobovrum at gmail.com
Wed Apr 11 09:37:48 PDT 2012
On Wednesday, 11 April 2012 at 16:33:42 UTC, Simen Kjaeraas wrote:
> On Wed, 11 Apr 2012 18:08:14 +0200, Russel Winder
> <russel at winder.org.uk> 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;
}
-----------
More information about the Digitalmars-d
mailing list