News for hackers. Stuff that matters.
Re:Maybe Functions by metalrain on Monday March 11, 2024 @09:04AM (#39667705)
You can also handle optionality when using the value.

  function maybeRenderBestFriends() {
    const user = maybeGetUser();
    if (!user) {
      return null
    }
    const friends = maybeGetFriends(user);
    const bestFriends = friends ? filterBestFriends(friends) : null;
    return bestFriends ? render(bestFriends) : null;
  }

There are no comments on this comment yet.