Dart naming convention

时间秒杀一切 提交于 2021-01-29 04:48:00

问题


Why in dart we have String not string

Other types are in lower case

  • int not Int
  • double not Double

回答1:


The reason for the naming was to make Dart more familiar to people coming from Java (or C#, but mostly Java). That's why int, double, bool and void are lower-case and String is capitalized, because that's what they were in Java (although boolean was considered too damn long). The num type got looped in too, because it's so closely tied to int and double, and dynamic was lower case to mark it as a special type, like void. (Special types added later, like FutureOr or Never, were not made lower case because that increased the risk of conflicting with existing variable names, something the original language didn't have to worry about.)

Dart does not have primitive types like, say, Java. All Dart values are objects, and you can call methods on them.




回答2:


Primitive types are starting with lower case (int, double, char ...). String is not a primitive type its an object therefore it doesn't start with lower case



来源:https://stackoverflow.com/questions/64952396/dart-naming-convention

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!