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
diesieben07
12/09/2018, 9:09 PM
action: (ViewModel) -> Unit
passes that requirement.
s
Shan
12/09/2018, 9:10 PM
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
diesieben07
12/09/2018, 9:11 PM
Can you show your code?
s
Shan
12/09/2018, 9:11 PM
Yes I will make a snippet, one moment
Shan
12/09/2018, 9:23 PM
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.