具有"val Capacity:Int"的任何原因均不适用.而不是"val Int Capacity"在斯卡拉 [英] Any reason for having "val capacity : Int" instead of "val Int Capacity" in Scala

查看:96
本文介绍了具有"val Capacity:Int"的任何原因均不适用.而不是"val Int Capacity"在斯卡拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读Scala,我想知道...
为什么

I am reading Scala and I am wondering ...
Why

val capacity : Int 

代替

val Int capacity.

做出此选择的任何原因.如果不是这样,在我看来似乎不是摆脱Java声明方式的好选择.本来可以使从Java到Scala的过渡更加容易(不是很多,但只有一点点)

Any reason why this choice was made. If not, it does not seem to me like a good choice to move away from the Java way of declaring it. Would have made the transition from Java to Scala easier (not by much, but little bit)

推荐答案

因为大部分时间您都可以忽略Int部分. Scala具有比Java更整洁的类型推断系统.

Because the majority of the time you can leave off the Int part. Scala has a much neater system of type inference than Java does.

这篇关于具有"val Capacity:Int"的任何原因均不适用.而不是"val Int Capacity"在斯卡拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆