Skip to content

Clarify "the new" in dependent function types #3794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 12, 2018
Merged
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions docs/docs/reference/dependent-function-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ title: "Dependent Function Types"
A dependent function type describes functions where the result type may depend
on the function's parameter values. Example:

class Entry { type Key; key: Key }
class Entry { type Key; val key: Key }

def extractKey(e: Entry): e.Key = e.key // a dependent method
val extractor: (e: Entry) => e.Key = extractKey // a dependent function value

// ║ ⇓ ⇓ ⇓ ⇓ ⇓ ⇓ ⇓ ║
// ║ Dependent ║
// ║ Function Type ║
// ╚═══════════════════╝
Scala already has _dependent methods_, i.e. methods where the result
type refers to some of the parameters of the method. Method
`extractKey` is an example. Its result type, `e.key` refers its
Expand Down