File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,14 @@ title: "Dependent Function Types"
6
6
A dependent function type describes functions where the result type may depend
7
7
on the function's parameter values. Example:
8
8
9
- class Entry { type Key; key: Key }
9
+ trait Entry { type Key; val key: Key }
10
10
11
11
def extractKey(e: Entry): e.Key = e.key // a dependent method
12
12
val extractor: (e: Entry) => e.Key = extractKey // a dependent function value
13
-
13
+ // ║ ⇓ ⇓ ⇓ ⇓ ⇓ ⇓ ⇓ ║
14
+ // ║ Dependent ║
15
+ // ║ Function Type ║
16
+ // ╚═══════════════════╝
14
17
Scala already has _ dependent methods_ , i.e. methods where the result
15
18
type refers to some of the parameters of the method. Method
16
19
` extractKey ` is an example. Its result type, ` e.key ` refers its
You can’t perform that action at this time.
0 commit comments