kotlin create a map with data init
April 3rd, 2023
val data = mutableMapOf<String,String>(
    "username" to "王菲",
    "age" to "18"
)

如果这里面还希望加上if else 是否可以呢,可以的

val age = "18"
val data = mutableMapOf<String, Any>(
    "username" to "王菲",
    "age" to age.toInt(),
    "adult" to if (age.toInt() >= 18) {
        "成年人"
    } else {
        "未成年人"
    }
)
Subscribe to wincloud
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.
More from wincloud

Skeleton

Skeleton

Skeleton