ktoso / scala-types-of-types

Scala's Types of Types

Home Page:ktoso.github.io/scala-types-of-types

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type Ascription vs. Type Annotation in section 3

vladap opened this issue · comments

I believe that what is called Type Ascription in section 3 is actually called Type Annotation in Scala. Type Ascription is a bit different. See Scala documentation which states:

Type ascription is often confused with type annotation, as the syntax in Scala is identical. The following are examples of ascription:

Nil: List[String]
Set(values: _*)
"Daniel": AnyRef

Ascription is basically just an up-cast performed at compile-time for the sake of the type checker. Its use is not common, but it does happen on occasion. The most often seen case of ascription is invoking a varargs method with a single Seq parameter. This is done by ascribing the _* type (as in the second example above).

Ascription follows the type annotation conventions; a space follows the colon.

Hence I think section 3 should be renamed to Type Annotation and new section could be created for Type Ascription.

Yes indeed. Would you submit a PR with this fix? Thanks a lot in advance!