|
|
|
|
|
by bigger_cheese
3393 days ago
|
|
That was really well written. As I was reading through the example code in the section about closures let add_one = |x| x + 1;
let five = add_one(4);
I thought to myself "hmm I wonder what happens if I were to call the code with a float rather than an int?"Answered my question a few paragraphs down. Kudos. Is it possible to write a generic closure? i.e something that would add 1 to any numeric type. |
|
I absolutely love it when a blog post, talk, or docs like these do that.
Especially during talks. Often the speaker will say something and it will immediately pop up questions in my mind which I really really want to ask but of course I should wait till the end. And then they answer it in the next slide. Perfect :)