4
maxnar
5y

Just found a 'Maybe' class that wraps an instance for null-safety. With arbitrary behaviour.
Like a good ol' if was a scary thing

Comments
  • 1
    That's actually pretty useful. Languages like C# and Kotlin have it built in.
  • 3
    That's like saying assembly suffices for everything, why bother with abstraction?

    Maybe makes it easy to write null-safe code, I don't see why that's a bad thing. And it's far easier to compose than if statements, especially if you're following a monadic style where Maybe forms a very convenient monad.
  • 0
    so in theory, a good thing, unless it was written by *that* guy at work, you know the one...
  • 0
    Rust has an Option<T> type. Super useful, and I hope PHP core had that as well. Same for Result<T, U>.
  • 0
    Same in Java, it has an Optional<>. And Kotlin is also null-safe by default. Even C++ has an optional<> template these days. It's funny to call it Maybe, but its a common approach.
Add Comment