<Kotlin: Passing constructors to functional interf...
# stackoverflow
r
Kotlin: Passing constructors to functional interfaces I saw my friend do this in his codebase, but I'm struggling to figure out how to do it with my class. Suppose I have the following code: class JobTest { fun interface JobCompiler { fun compile(s: String, l: Long): Job } data class Job(val name: String, val id: Long) } fun main() { val compiler = JobTest.JobCompiler { s: String, l: Long -> JobTest.Job(s, l) } val job = compiler.compile("Tom", 100) println("Name: ${job.name}, Id: ${job.id}") // Prints Name: Tom, Id: 100 }...