4 ms·
I don't write java, but assuming it has a null coalescing operator you can likely do all that in a single map in a way that is (in my opinion) cleaner and easie
by cmeacham98 5y ago
I don't write java, but assuming it has a null coalescing operator you can likely do all that in a single map in a way that is (in my opinion) cleaner and easier to read than both of your examples.
- erik_seaberg 5y agoKotlin does but sadly Java’s Optional<T> has no syntactic sugar, so it ends up looking like Optional.ofNullable(user).map(User::getUsername).map(name -> name.contains(searchString))