Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/docs/reference/singleton-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
layout: doc-page
title: "Literal Singleton Types"
---

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

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

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

```scala
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](http://docs.scala-lang.org/sips/pending/42.type.html)
2 changes: 2 additions & 0 deletions docs/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ sidebar:
url: docs/reference/implicit-function-types.html
- title: Phantom Types
url: docs/reference/phantom-types.html
- title: Literal Singleton Types
url: docs/reference/singleton-types.html
- title: Enums
subsection:
- title: Enumerations
Expand Down