Questions tagged «ascription»

5
Scala中的类型归属的目的是什么?
规范中没有太多有关类型归属的信息,并且当然没有关于目的的任何信息。除了“使传递的varargs起作用”之外,我还要使用类型归属?以下是一些scala REPL,以了解使用它的语法和效果。 scala> val s = "Dave" s: java.lang.String = Dave scala> val p = s:Object p: java.lang.Object = Dave scala> p.length <console>:7: error: value length is not a member of java.lang.Object p.length ^ scala> p.getClass res10: java.lang.Class[_ <: java.lang.Object] = class java.lang.String scala> s.getClass res11: java.lang.Class[_ <: java.lang.Object] = …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.