24.7 Combining ? Operator with Result Types
Right, so you’ve met the optional chaining operator (?.), that brilliant little piece of syntactic sugar that lets you navigate potential null or undefined without blowing up your entire application. And you’ve probably also been introduced to the idea of Result (or Either) types, a more structured and type-safe way of representing failure than just throwing errors into the void and hoping someone catches them. You might be wondering: “Can I use these two beautiful things together?” The answer is a resounding “Yes, but… oh dear god, be careful.” It’s like using a chainsaw to make a fine wood carving. Powerful, but one wrong move and you’ve accidentally validated a null value as a successful operation. Let’s talk about how to do it right.