https://kotlinlang.org logo
#announcements
Title
# announcements
m

miha-x64

04/14/2017, 11:48 AM
By the way, which is better — Java way with None and Some declared as one class (Optional), or Scala way with sealed class (actually, three classes instead of one)? I have single-class Either implementation, bit it has extra flag which says whether it is left or right.
a

Andreas Sinz

04/15/2017, 8:52 AM
I'd go with the sealed class approach with multiple classes in order to have a single responsibility (makes the code cleaner IMHO, because if i want to look at the behaviour of None, i have to skim through if/else and find out which one belongs to None)
Optional is like the Strategy Pattern
2 Views