Skip to content

Commit 9914606

Browse files
authored
Create new doc page for Literal Singleton Types
1 parent a527f3b commit 9914606

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
layout: doc-page
3+
title: "Literal Singleton Types"
4+
---
5+
6+
Literal Singleton Types allows primitive literals to be used as types. For example:
7+
8+
```scala
9+
val t: 42 = 42
10+
val t: "Jedi" = "Jedi"
11+
```
12+
13+
It is also possible to define functions returning or taking singleton types such as
14+
15+
```scala
16+
def f(t: Double): t.type = t
17+
val a: 1.2 = f(1.2)
18+
```
19+
20+
For more details and the motivation behind the need for literal singleton types, check out [SIP-23](http://docs.scala-lang.org/sips/pending/42.type.html)

0 commit comments

Comments
 (0)