Similar. While it will create self enforced singletons. It isn't the goal. The goal is to not use null. So if my Reference Types have a Default property, I can use that instead of default or null for my checks.
Comments
Log in with your Bluesky account to leave a comment
Not that I can think of.
Such semantics could get quite tricky in a generic context, especially when unconstrained.
Off the top of my head, you may perhaps introduce an `I(Default)Creatable` interface to your app or domain, and implement a `static abstract T Create(Default)` method on your types.
Comments
Person p = default;
and instead of null, it uses a custom logic, like the Default property.
Such semantics could get quite tricky in a generic context, especially when unconstrained.
Off the top of my head, you may perhaps introduce an `I(Default)Creatable
Default is null for a Reference Type. So you cannot use the default keyword.
That is why I want to generate a proper Default, but I don't want my devs to have to maintain a Default parameter.