April 14, 2004 up cast in foreach? | ||||
|---|---|---|---|---|
| ||||
will it be valid?
for 1.0?
#############
class A
{
}
class B : A
{
}
int main(char[][] args)
{
B b;
A a = b;
B[] bs;
a = bs[123]; // valid
foreach(A a ; bs) // invalid
{
}
return 0;
}
############
dmd ../C.d -I~/dmd/src/phobos
../C.d(20): foreach: B [] is not an array of A
############
if A is an interface the compiler produces the same message.
Ant
| ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply