You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Generics chapter, could we add an example showing how to call a function with a type parameter that cannot be inferred? Specifically, this happens when a function returns a value with a type that cannot be inferred from its parameters. I wondered about this when playing with generics after reading the chapter. Gopls showed me how to do it, but I think adding an example of this to the book could be helpful.
For a concrete example, we could add a constructor for the type Stack[T] introduced in the chapter:
In the Generics chapter, could we add an example showing how to call a function with a type parameter that cannot be inferred? Specifically, this happens when a function returns a value with a type that cannot be inferred from its parameters. I wondered about this when playing with generics after reading the chapter. Gopls showed me how to do it, but I think adding an example of this to the book could be helpful.
For a concrete example, we could add a constructor for the type
Stack[T]
introduced in the chapter:which requires the type
T
to be specified when calling, e.g.:This example could be added to the end of the section Next: Generic data types.
If this sounds good to you, I'd be happy to write it and make a PR.
The text was updated successfully, but these errors were encountered: