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
var max = 10; | |
for (int i = 1 ; i <= max ; i++) { | |
// ... | |
} |
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
data class User(val name) | |
interface UserDataSource { | |
fun getAllUsers( | |
onSuccess: (users: List<User>) -> Unit, | |
onError: (err: Throwable) -> Unit | |
) | |
} | |
// class UpdateDataSourceImpl: UserDataSource { .... } |
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 InitOrderDemo(name: String) { | |
val firstProperty = "First property: $name".also(::println) | |
init { | |
println("First initializer block that prints ${name}") | |
} | |
val secondProperty = "Second property: ${name.length}".also(::println) | |
init { |
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
val sum = a ?: (0 + b) |
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
val a: Int? = 10 | |
val b: Int = 10 | |
val sum = a ?: 0 + b |
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
var max = 10 | |
val range = IntRange(1, max) | |
for (i in range) { | |
// ... | |
} |
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
var max = 10 | |
for (i in 1..max) { | |
// ... | |
} |
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
data class User(val name) | |
interface UserDataSource { | |
fun getAllUsers( | |
onSuccess: (users: List<User>) -> Unit, | |
onError: (err: Throwable) -> Unit | |
) | |
} | |
// class UpdateDataSourceImpl: UserDataSource { .... } |
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
val answer: Int by lazy { | |
computeAnswer() | |
} | |
fun computeAnswer() = 42 |
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
private const val DURATION_IN_MS = 3000L | |
val fadeInAnimation = AlphaAnimation(0f, 1f).apply { | |
duration = DURATION_IN_MS | |
interpolator = AccelerateDecelerateInterpolator() | |
fillAfter = true | |
} |
NewerOlder