: User data class User(val name: String, val twitterId: String, val githubId: String, val company: String) print("Name : ${aakira.name}”) println("Github Id : ${aakira.githubId}") print("Twitter Id : ${aakira.twitterId}") println("Company : ${aakira.company}") $ whois
// Java class Hoge { private String foo; private int bar; Hoge(String foo, int bar) { ... } public String getFoo() { return foo; } ... } // Kotlin data class Hoge(var foo: String, var bar: Int)
三項演算子に置き換え可能 • when : switchの進化版(Kotlinにswitchはない) • for : for-eachのみ(Kotlinにfor(int i = 0; i <…)はない) • while : Javaと同じ // if val hoge = if(foo > bar) 10 else 100 // when val hoge = when(foo) { 0 -> "a" 1 -> "b" else -> "c" } // for for (item in hogeList) { result += item }