Last active
September 5, 2018 21:48
-
-
Save adibfara/2613991c39d8249eda09e7668f50a156 to your computer and use it in GitHub Desktop.
Kotlin contracts
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
/** | |
* @author Adib Faramarzi (adibfara@gmail.com) | |
*/ | |
fun createOnce(runFunction: ()-> Unit) { | |
runFunction() | |
} | |
fun getKotlinVersion(): Float{ | |
val kotlinVersion: Float | |
createOnce { | |
kotlinVersion = 1.3f | |
} | |
// The line below generates the error (and does not compile): | |
// Captured values initialization is forbidden due to possible reassignment | |
return kotlinVersion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment