Model Closed Variants in Ceylon with `of` and Exhaustive `switch`
Ceylon’s `of` clause creates closed variant sets and its exhaustive `switch` turns adding a new case into a compiler-guided refactor instead of a code-review gamble.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Ceylon’s `of` clause creates closed variant sets and its exhaustive `switch` turns adding a new case into a compiler-guided refactor instead of a code-review gamble.
Ceylon removes Java's wildcard boilerplate with declaration-site variance and type inference, but JVM erasure means bridge methods and hidden casts remain. Here is how to verify the tradeoff before adopting it.
A task guide to declaring a Ceylon module descriptor, resolving dependencies, compiling, running, and packaging a self-contained JVM archive with the Ceylon CLI.
Discover how Ceylon’s strong static typing and nullable type markers eliminate NullPointerExceptions at compile time. Learn with a hands‑on example, trade‑offs, and how to get started.
Ceylon forces API opt-in with the shared modifier and separates compile-time import from implementation use in module.ceylon, letting you keep a module surface small and auditable.
Use Ceylon’s union/intersection types and null‑safe optionals to build a small, JVM‑friendly domain model. This guide maps requirements to a minimal design, defines interop boundaries, and lists operational checks and failure modes.
Learn how Ceylon’s union types and match expressions let you handle Java nulls safely at compile time, reducing runtime surprises when calling existing Java libraries.
A diagnostic guide for Ceylon programs where a nullable union type (String?) slips past apparent null checks: how flow-based narrowing fails, how to find the break, and which fix matches each cause.
Discover how Ceylon’s union and intersection types let you design APIs that return success or error values, model multi‑interface objects, and keep type safety intact at runtime. A concrete example shows the compiler’s handling and the trade‑offs you need to weigh.