|
|
|
|
|
by yoz-y
3116 days ago
|
|
Returning an empty list or empty array is different from returning no list at all. Imagine I want to query a database of tagged articles. Let's say I want to get articles with an exact set of tags. Passing this method [A, B] will give me articles with tags A and B, passing this method [] will give me articles with no tags. Not specifying the query parameter at all will result in no parameter. I could use a boolean value to keep track of that or just use an optional. |
|
If your contract says you return a Foo, you could be returning a null. If you change that to Optional<Foo> you could still be returning a null.
It's not what Optionals are for. They are just widely misunderstood and abused.