- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add dispatch on parametric types in doc #13453
Conversation
sqrt(p.x^2 + p.y^2) | ||
end | ||
|
||
The correct way to define a method that accepts all arguments of ``Point`` types where ``T`` is a subtype of ``Real`` is:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"of type Point
", maybe?
The text is really great, but there probably needs to be more of a transition into this new topic, which seems distinct from the constructors discussed immediately above. |
|
||
The correct way to define a method that accepts all arguments of ``Point`` types where ``T`` is a subtype of ``Real`` is:: | ||
|
||
function norm{T <: Real}(p::Point{T}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the convention is to write {T<:Real}
to me (though it's hard to be sure...).
Good idea! |
Thanks for the comments — updated the pull request. |
Add dispatch on parametric types in doc
backported in 7048c40 |
[av-skip] This issue with type invariance often comes up.