Skip to content

Instantly share code, notes, and snippets.

Marcin Moskała MarcinMoskala

Block or report user

Report or block MarcinMoskala

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TypingSystem.kt
fun processPerson(person: Person?) {
val name = person?.name ?: return
// ...
}
View TypingSystem.kt
fun printTextOrNull(text: String?) {
print(text)
}
fun main() {
printTextOrNull("AAA")
printTextOrNull(null)
}
View TypingSystem.kt
val a = if(predicate) "A" else null
val b = when {
predicate2 -> "B"
predicate3 -> "C"
else -> null
}
View TypingSystem.kt
val a by PropDelegate()
class PropDelegate {
operator fun getValue(thisRef: Nothing?, property: KProperty<*>): Any {
TODO()
}
}
View TypingSystem.kt
val a by PropDelegate()
class PropDelegate {
operator fun getValue(nothing: Nothing?, property: KProperty<*>): Any {
TODO()
}
}
View TypingSystem.kt
fun processPerson(person: Person?) {
val name = person?.name ?: return
val surname =
if(person.surname.isNotBlank()) person.surname
else return
//...
}
fun describeNormalNum(num: Int) {
val description = when {
View TypingSystem.kt
fun describeNormalNum(num: Int) {
val description = when {
num % 2 == 0 -> "Is even"
num % 2 == 1 -> "Is odd"
else -> throw Error()
}
print(description)
}
View Unit.kt
public object Unit {
override fun toString() = "kotlin.Unit"
}
View TypingSystem.kt
fun processPerson(person: Person?) {
val name = person?.name ?: throw Error()
//...
}
View TypingSystem.kt
fun processPerson(person: Person?) {
val name = person?.name ?: throw Error()
//...
}
You can’t perform that action at this time.