News for hackers. Stuff that matters.
Re:“Coding is basically just ifs and for loops.” by cmeacham98 on Saturday December 04, 2021 @08:17PM (#29445921)
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.
Re:“Coding is basically just ifs and for loops.” by erik_seaberg on Saturday December 04, 2021 @11:05PM (#29446610)
Kotlin 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))