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"
66A dependent function type describes functions where the result type may depend
77on 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+ // ╚═══════════════════╝
1417Scala already has _ dependent methods_ , i.e. methods where the result
1518type refers to some of the parameters of the method. Method
1619` extractKey ` is an example. Its result type, ` e.key ` refers its
You can’t perform that action at this time.
0 commit comments