码迷,mamicode.com
首页 > 其他好文 > 详细

[Dart] final vs const

时间:2019-08-19 21:03:50      阅读:75      评论:0      收藏:0      [点我收藏+]

标签:nal   ble   pre   hello   cti   ice   rac   sse   diff   

void main() {
  var a = 1;
  print(a);

  int b = 2;
  print(b);

  final c = Hello;
  // c = ‘Hello again‘; // Uncomment to throw
  print(c);

  const d = World;
  print(d);
}

 

If we attempt to reset ‘final‘ to a different value, we will get an error. The difference in practice between const and final is you use final when certain instance variables belong into classes.

[Dart] final vs const

标签:nal   ble   pre   hello   cti   ice   rac   sse   diff   

原文地址:https://www.cnblogs.com/Answer1215/p/11379403.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!