1

I know there's a concept of flow-sensitive typing in Ceylon in which we can narrow down the type of an expression by case. Is there a way to explicitly convert the type of an expression in Ceylon as in Java?

Baber
  • 301
  • 2
  • 6
  • 17

1 Answers1

3

As a statement:

assert(variable is NarrowType);

I don’t remember if there’s a recommended way to do that as an expression, but you could always put the above (plus return variable;) into a generic function and call it with your expression

Lucas Werkmeister
  • 2,584
  • 1
  • 17
  • 31