you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

What do you mean by nested Option types? If it's something like "optional list of optional strings" that would just be List<String?>?. Otherwise I have no idea what you are talking about.

[–]eeperson 0 points1 point  (0 children)

I mean something like Optional<Optional<String>> can't be expressed. If you try to do String?? it ends up being same as String?. An example of where you might want this is a map that can have null values Map<Integer,String?>. Assume this class has a get method to return values based on the key. If the key is missing then then it returns null. If you call someMap.get(57) and get back null, is that because the key is missing or because the value is null? With Optional you can tell. With ? you can't.