Building Optional from scratch

From this article 2 Minute Tips: The Dark Secret of Optionals I got to know that the Optionals are nothing but an Enum . I started experimenting: How can we build Optional from scratch Enter Schrödinger's Cat or … a box You might have heard of Schrödinger’s Cat — the thought experiment where a cat in a box is both alive and dead until you check. That's basically an Optional, right? A value that might exist... or not. So, let's turn this idea into code: enum

May 2, 2025 - 14:16
 0
Building Optional from scratch

From this article 2 Minute Tips: The Dark Secret of Optionals I got to know that the Optionals are nothing but an Enum . I started experimenting: How can we build Optional from scratch

Enter Schrödinger's Cat or … a box

You might have heard of Schrödinger’s Cat — the thought experiment where a cat in a box is both alive and dead until you check. That's basically an Optional, right? A value that might exist... or not.

So, let's turn this idea into code:

enum