Re: [Vala] casting out parameters



Would love to see this dynamic casting supported by the language.. Should I open a bug?

----- Original message -----
On Tue, 2010-05-25 at 11:12 +0200, pancake wrote:
How can I cast an out parameter?

public class Foo {}
public class Bar : Foo {}

void test(out Foo foo) {
      foo = new Bar ();
}

void main() {
      Bar bar;
      test (out bar);
}

a.vala:10.9-10.15: error: Argument 1: Cannot convert from `Foo' to `Bar?'

More verbose error message: test(out Foo foo), considered
as a black box, may assign to foo any descendant of Foo,
not necessarily Bar.

Try:
      Foo x;
      test (out x);
      Bar bar = x as Bar;

hand
Nor Jaidi Tuah





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]