KOTLIN_BROADCAST Telegram 1921
🏝 В Kotlin 2.2.20 прокачали работу exhaustive when

enum class UserRole { ADMIN, MEMBER, GUEST }

fun getPermissionLevel(role: UserRole): Int {
// Проверяем один кейс из Enum до работы с when
if (role == UserRole.ADMIN) return 99

return when (role) {
UserRole.MEMBER -> 10
UserRole.GUEST -> 1
// С Kotlin 2.2.20 не надо добавлять else,
// так как кейс уже был проверен выше
// else -> throw IllegalStateException()
}
}


Фича экспериментальная и требует включения через опции

#kotlin
Please open Telegram to view this post
VIEW IN TELEGRAM
👍67🔥26🤔161



tgoop.com/kotlin_broadcast/1921
Create:
Last Update:

🏝 В Kotlin 2.2.20 прокачали работу exhaustive when

enum class UserRole { ADMIN, MEMBER, GUEST }

fun getPermissionLevel(role: UserRole): Int {
// Проверяем один кейс из Enum до работы с when
if (role == UserRole.ADMIN) return 99

return when (role) {
UserRole.MEMBER -> 10
UserRole.GUEST -> 1
// С Kotlin 2.2.20 не надо добавлять else,
// так как кейс уже был проверен выше
// else -> throw IllegalStateException()
}
}


Фича экспериментальная и требует включения через опции

#kotlin

BY Kotlin Multiplatform Broadcast


Share with your friend now:
tgoop.com/kotlin_broadcast/1921

View MORE
Open in Telegram


Telegram News

Date: |

As of Thursday, the SUCK Channel had 34,146 subscribers, with only one message dated August 28, 2020. It was an announcement stating that police had removed all posts on the channel because its content “contravenes the laws of Hong Kong.” The administrator of a telegram group, "Suck Channel," was sentenced to six years and six months in prison for seven counts of incitement yesterday. The public channel had more than 109,000 subscribers, Judge Hui said. Ng had the power to remove or amend the messages in the channel, but he “allowed them to exist.” How to Create a Private or Public Channel on Telegram? How to Create a Private or Public Channel on Telegram?
from us


Telegram Kotlin Multiplatform Broadcast
FROM American