Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jaspersprengers
Last active February 4, 2018 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaspersprengers/ea7e6944d4e784b36b6904061cd4c372 to your computer and use it in GitHub Desktop.
Save jaspersprengers/ea7e6944d4e784b36b6904061cd4c372 to your computer and use it in GitHub Desktop.
Two ways to define a functional interface implementation
class BitCoinToDollarConverter : (Double) -> Double {
override fun invoke(bitcoins: Double) = bitcoins * 10000 * Random().nextDouble()
}
//version with operator
class BitCoinToDollarConverter {
operator fun invoke(bitcoins: Double) =
bitcoins * 10000 * Random().nextDouble()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment