<Neglecting parameters when casting a function tha...
# forum
r
Neglecting parameters when casting a function that returns Unit Is there a way to cast a lambda say () -> Unit to a (String) -> Unit? Specifically in constructors? Currently, my get around is just wrapping it with another lambda as follows val x: () -> Unit = { println("x has fired") } val xMapped: (String) -> Unit = { x() } Why does the compiler not neglect the argument in this case so I can do val xMappedBetter: (String) -> Unit = x // Can't cast! In fact, if it was really smart, and you didn’t have duplicated parameters couldn’t it even handle...