Re: [Vala] casting out parameters
- From: pancake <pancake youterm com>
- To: vala-list gnome org
- Subject: Re: [Vala] casting out parameters
- Date: Wed, 26 May 2010 20:23:25 +0200
And if it's a subclass? Which is what 'as' does.
----- Original message -----
On Wed, 2010-05-26 at 15:41 +0200, pancake wrote:
Would love to see this dynamic casting supported by the language..
Should I open a bug?
As Nor Jaidi Tuah wrote, the declaration of the method `test` does not
guarantee that `foo` is set to an instance of `Bar`. The method could
also be implemented as follows:
void test(out Foo foo) {
foo = new Foo ();
}
If the compiler accepted your `main` method, you'd have a variable of
type Bar pointing to an object of type Foo, and this should never
happen. The compile error you get is intentional and not a bug.
Jürg
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]