You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Declarationenum Distance {
case Kilometers(public int $km);
case Miles(public int $miles);
}
// Usage$walk= Distance::Miles(500);
print$walk->miles; // prints "500"
These are very similar to Kotlin's sealed classes: In some sense, sealed classes are similar to enum classes: the set of values for an enum type is also restricted, but each enum constant exists only as a single instance, whereas a subclass of a sealed class can have multiple instances, each with its own state..
Activity
thekid commentedon Mar 13, 2021
First implementation idea:
thekid commentedon Dec 21, 2025
To match on these, xp-lang/php-is-operator#2 will come in handy