-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Miscellaneous minor improvements #2370
Conversation
src/generics/generic-functions.md
Outdated
@@ -19,7 +19,7 @@ fn pick<T>(n: i32, even: T, odd: T) -> T { | |||
|
|||
fn main() { | |||
println!("picked a number: {:?}", pick(97, 222, 333)); | |||
println!("picked a tuple: {:?}", pick(28, ("dog", 1), ("cat", 2))); | |||
println!("picked a tuple: {:?}", pick(28, "dog", "cat")); |
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.
These aren't tuples anymore. I guess that would be "picked a string"
. But the idea here was to show that T doesn't just have to be a named type like String
or i32
, but can be any type.
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.
I agree, I would add this as an additional example so the students see two "simple" types as well as a compound type.
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.
Hrm, I get what you're saying about demonstrating that generic types can also be compound types, though I don't think it's all that important to emphasize. I think students can generalize from "integers and strings" to "any type". But saying it explicitly to students might be good, so would it be good enough to add a speaker note about it?
Various little changes that I've wanted when going through classes. Let me know if any of these seem problematic, I can pretty easily remove any commits that would be better to discuss separately.