Hacker News new | ask | show | jobs
by MadsTorgersen 3219 days ago
"If let" could be easily mirrored by a pattern in C#, and we are starting to discuss that.

However, that's a new way to check for null in the language, where what we need is to recognize the ways people are already checking for null in billions of lines of code. Therefore, the priority is to do a good flow analysis that will just understand when a nullable variable can be assumed to not be null (e.g. after a check, a non-null assignment, etc.), and then let you dereference without challenge.

1 comments

If c# 8 has good flow for checking null, then no need "if let". If let also has disadvantage, backward compartibility. For example, maybe i want change my logic class to c# 2