Dotty Documentation

0.5.0-bin-SNAPSHOT

Literal Singleton Types

Edit this page on GitHub

Literal Singleton Types allows primitive literals to be used as types. For example:

val t: 42 = 42
val x: "Jedi" = "Jedi"

It is also possible to define functions returning or taking singleton types such as

def f(t: Double): t.type = t
val a: 1.2 = f(1.2)

For more details and the motivation behind the need for literal singleton types, check out SIP-23