[Vala] Ternary operator and nullable values in return statements



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;
}

Am I missing something obvious of misunderstanding something equally clear?

Seems to produce this error whenever the return type is nullable and
null is one of the evaluations of the ternary operator.

best wishes

dru



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