简体   繁体   English

Dart 中的 null 安全性有什么意义?

[英]What is the point of null safety in Dart?

空值安全点是否可以防止意外将null分配给变量,然后再执行类似nullable_variable.foo()之类的操作,这会导致运行时错误?

Yes :是的

With null safety, your runtime null-dereference errors turn into edit-time analysis errors.使用 null 安全性,您的运行时null 取消引用错误会变成编辑时分析错误。

It means that a lingering problem that would otherwise become known only when its already too late will turn into an error that you get while you are developing, so you will know about it and can fix it before it ever reaches a customer.这意味着一个挥之不去的问题,否则只有在为时已晚时才会知道,这将变成您在开发时遇到的错误,因此您将了解它并可以在它到达客户之前对其进行修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM