Skip to content

Instantly share code, notes, and snippets.

@humblerookie

humblerookie/ParserInstance.kt Secret

Last active Jul 17, 2020
Embed
What would you like to do?
Sample non lambda instantiation
fun oldInstantiation() {
val defaultParser = object : Parser{
override fun parse(value: String): ParsedOutput {
require(value.length > 4)
ParsedOutput(value.substring(0, 3), value.substring(3, value.length))
}
}
}
fun newInstantiation() {
val defaultParser = Parser { value ->
require(value.length > 4)
ParsedOutput(value.substring(0, 3), value.substring(3, value.length))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.