| > > Can I write a method that's polymorphicly nullable? > Sure. You should see the crazily cool stuff we can do with stuff like the signature of max(). You'll be impressed, I promise! From the docs: > A nonempty iterable is an iterable object which always produces at least one value. A nonempty iterabe type is written {String+}. Distingushing nonempty streams of values lets us correctly express the type of functions like max(): > {Float+} oneOrMore = .... ; > {Float*} zeroOrMore = .... ; > Float maxOfOneOrMore = max(oneOrMore); //never null > Float? maxOfZeroOrMore = max(zeroOrMore); //might be null While this is interesting, is it enforced by the compiler? i.e. is the following a runtime, or compile time error?: Float maxOfOneOrMore = max(zeroOrMore);
|
Of course. That's the whole point. I really think you've missed the nature of Ceylon. Don't imagine, that just because it has a syntax that looks friendly and harmless and familiar, that it doesn't have a really killer type system under the hood.
> i.e. is the following a runtime, or compile time error?
A compile-time error, of course.