Hello all. I have a question I'm unsure how to goo...
# getting-started
s
Hello all. I have a question I'm unsure how to google. Is it possible to have a function which takes as a parameter
anything that extends x
? For example I have a data class here (using tornadofx library, it provides the ViewModel class) which I would like for the lamda to take anything which extends a ViewModel.
Copy code
data class CustomMenuItem (val name: String, val action: (E ? extends ViewModel) -> Unit)
d
action: (ViewModel) -> Unit
passes that requirement.
s
That is what I had before, but after passing in a "NameModel" class which extends a ViewModel it says a ViewModel was required, not a NameModel.
d
Can you show your code?
s
Yes I will make a snippet, one moment
Nevermind, sorry my question was not what I was really needing to know. I had my colleague help me with it and he told me the same thing you did and then I realized I was doing everything the wrong way lol. Thank you though.
d
No problem, glad to help