April 06, 2009 cast a LinkSeq | ||||
---|---|---|---|---|
| ||||
Hi All, can I cast a LinkSeq from inherited type to base type? ------------------------ code -------------------------- class Fruit {} class Apple: Fruit {} auto apples = new LinkSeq!(Apple); apples.append(new Apple); assert(apples !is null); assert(apples.length == 1); auto fruits = cast(LinkSeq!(Fruit))(apples); assert(fruits !is null); // <--- failed assert(fruits.length == 1); ------------------------ code -------------------------- --Qian |
April 06, 2009 Re: cast a LinkSeq | ||||
---|---|---|---|---|
| ||||
Posted in reply to Qian Xu | Qian Xu wrote: > Hi All, > > can I cast a LinkSeq from inherited type to base type? What I can do, is to create a new LinkSeq!(Fruit) and then cast all elements one by one. -- Xu, Qian (stanleyxu) http://stanleyxu2005.blogspot.com |
Copyright © 1999-2021 by the D Language Foundation