-
-
Save jaspersprengers/ea7e6944d4e784b36b6904061cd4c372 to your computer and use it in GitHub Desktop.
Two ways to define a functional interface implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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