I've got this generic function: <https://pl.kotl.i...
# getting-started
h
I've got this generic function: https://pl.kotl.in/cv6sdbHHy
my question is why does this compile?
oh should I put the code directly here instead of a playground link?
j
T
is inferred by the compiler, and in your case inferring
Any
makes it work, so the compiler chooses this
(yes if the code is small it's easier to just put it here)
👍 2
If you want to experiment or clarify those things, you can try specifying the type of
T
explicitly, as in:
Copy code
a.isOneOf<String>(1.2, 3)
And this will fail as you expect
👍 2
h
oh ok, got it. Thank you.