Function whose return type is supplied as parameter #2736
Unanswered
EvanBalster
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Wouldn't you know it, I figured it out right after opening the question. The 'capturing' backticks are unnecessary and removing them makes the function work as expected:
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello! I'm making a game engine that makes pervasive use of methods like
room:contents(Creature)
. Thecontents
method returns all objects that inherit from the type passed to the method. Therefore the return type equals the value of the first parameter.My first attempt:
My second:
With the second implementation,
room:contents(Creature)[1]
is reported as type<T>
rather than being of typeCreature
or the base class of Creature. Type information is lost and autocomplete does not produce any useful info.Beta Was this translation helpful? Give feedback.
All reactions