Skip to content

Commit b85a951

Browse files
authored
Merge pull request #3794 from soronpo/patch-1
Clarify "the new" in dependent function types
2 parents 8817f4c + 415525d commit b85a951

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/docs/reference/dependent-function-types.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ title: "Dependent Function Types"
66
A dependent function type describes functions where the result type may depend
77
on the function's parameter values. Example:
88

9-
class Entry { type Key; key: Key }
9+
trait Entry { type Key; val key: Key }
1010

1111
def extractKey(e: Entry): e.Key = e.key // a dependent method
1212
val extractor: (e: Entry) => e.Key = extractKey // a dependent function value
13-
13+
// ║ ⇓ ⇓ ⇓ ⇓ ⇓ ⇓ ⇓ ║
14+
// ║ Dependent ║
15+
// ║ Function Type ║
16+
// ╚═══════════════════╝
1417
Scala already has _dependent methods_, i.e. methods where the result
1518
type refers to some of the parameters of the method. Method
1619
`extractKey` is an example. Its result type, `e.key` refers its

0 commit comments

Comments
 (0)