Hi all,
I have SomeClass[TYPE] { def some_method(args: fixed_type_args): TYPE }
And on runtime, I create instances of this class with different AnyVal + String
types, but the return type of some_method varies.
I know I could do this with an implicit object, IF some_method received a type,
but in this case, I need to have the TYPE defined on its class instance, so for
example:
val int_instance = new SomeClass[Int]
val str_instance = new SomeClass[String]
val result: Boolean = int_instance.some_method(args) > 0 <--- I expected
INT here
val result2: Boolean = str_instance.som_method(args) contains "asdfg" <----
I expected STRING here.
without compilation errors.
Any ideas? I would like to implement something like this:
class SomeClass[TYPE] {
def some_method(args: Int): Int = {
process_integer_overloaded_method
}
def some_method(args: Int): String = {
process_string_overloaded_method
}
and so on.
Any ideas? maybe store classe's TYPE in a constructor instead as a variable
somehow?
Thanks
Saif