|
|
|
|
|
by stickfigure
3351 days ago
|
|
The syntax still looks tedious compared to Ceylon: if (is String name) {
// compiler knows 'name' is String in this block
print(name);
}
else {
print("some other text");
}
Why declare a new variable? The Ceylon syntax works great with union types too. |
|
https://news.ycombinator.com/item?id=12971841#12972691
In C#, the "wanting the supertype" answer makes some sense with explicit interface implementations [0]. Java doesn't have that, and AFAIK there's no way to declare something that's visible on a supertype but not a subtype.
[0] I think it's a bad reason. But the possibility does at least exist.