[Vala] Ternary operator and nullable values in return statements

2010-11-28 Thread Dru Moore
Hi all, Was surprised to see the following fail to compile with an error: Incompatible expressions in Vala 0.10.0 (simplified test case to illustrate): public static int main (string[] args) { int? x = test (12); return 0; } public int? test (int number) { return (0 == number) ? null : 1;

Re: [Vala] Ternary operator and nullable values in return statements

2010-11-28 Thread Jiří Zárevúcky
Dru Moore píše v Ne 28. 11. 2010 v 18:22 +: Hi all, Was surprised to see the following fail to compile with an error: Incompatible expressions in Vala 0.10.0 (simplified test case to illustrate): public static int main (string[] args) { int? x = test (12); return 0; } public

Re: [Vala] Ternary operator and nullable values in return statements

2010-11-28 Thread Dru Moore
2010/11/28 Jiří Zárevúcky zarevucky.j...@gmail.com: You need to cast it like this:  (0 == number) ? null : (int?) 1 or  int? i = 1;  (0 == number) ? null : i Thank you. That's it of course. cheers ___ vala-list mailing list vala-list@gnome.org