People are hating on this approach, but IMO the only reason people think this is bad or shows "unclear intent" is because it's new and they're unfamiliar with it.
It's extremely clear what this means, I don't know how you could get confused by this if you saw it in the code. Nobody has provided an example showing how this could be unclear.
Its weird what the use case is for this. I am having a hard time trying to think when i needed to know if a method exists. I might just be too used to working in typed languages now.
However, language features aren't usually inherently bad. Just don't use if you don't like it, duh.
Even in typed languages, e.g. C#, you can have a delegate for an event that might or might not be set. You can use the .? syntax to safely invoke the delegate if it exists, no need for if (delegate != null) { /* invoke */ }.
84
u/anon774 Nov 10 '20
People are hating on this approach, but IMO the only reason people think this is bad or shows "unclear intent" is because it's new and they're unfamiliar with it.
It's extremely clear what this means, I don't know how you could get confused by this if you saw it in the code. Nobody has provided an example showing how this could be unclear.