# kotlin create a map with data init **Published by:** [wincloud](https://paragraph.com/@wincloud/) **Published on:** 2023-04-03 **URL:** https://paragraph.com/@wincloud/kotlin-create-a-map-with-data-init ## Content 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 { "未成年人" } ) ## Publication Information - [wincloud](https://paragraph.com/@wincloud/): Publication homepage - [All Posts](https://paragraph.com/@wincloud/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@wincloud): Subscribe to updates