DART CONST构造函数 - 可能默认吗?

发布于 2025-02-06 03:34:25 字数 81 浏览 1 评论 0原文

如果我们从绒毛上收到警告来使用它,为什么不能推断const呢? 为什么,如果可能的话,所有类构造函数默认不是const? 这将使我们的代码更加干净。

Why can't const be inferred, if we get warnings from Lint to use it?
Why, if possible, all classes constructors aren't by default const?
This would let our code much more clean.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北方的韩爷 2025-02-13 03:34:25

使用const的要点不是协助编译器进行优化,而是保护自己免受错误,这意味着它可以防止您无意中修改您没想到会被修改的东西。

通常,当您没有太多变量时,它可以更轻松地编程A。
无需记住应该修改哪一个,哪个应该不应该进行。

The main point of using const is not to assist the compiler in optimizations but to protect yourself from mistakes which means it prevents you from inadvertently modifying something you didn't expect to be modified.

Generally it makes it easier to program a when there is too many variables you dont.
No need to memorize which one should be modified and which one shouldn't.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文