Jay Taylor's notes
back to listing indexGet companion object of class by given generic type Scala - Stack Overflow
[web search]
Original source (stackoverflow.com)
Clipped on: 2012-09-25
What I am trying to do is to make a function that would take a generic class and use a static method in it (sorry for Java language, I mean method of its companion object).
Any ideas?
| ||||
add comment | ||||
A gist by Miles Sabin may give you a hint:
This should be compiled with the | |||||||||||||||||||||||||||
|
You could use reflection to get the companion class and its instance, but that relies on Scala internals that might change in some far(?) future. And there is no type safety as you get an AnyRef. But there is no need to add any implicits to your classes and objects.
| |||||||||||||
|
Your Answer
community wiki