fun Double.toPlainString(): String
= BigDecimal.valueOf(this).toPlainString()
val d1 = 0.00000000000000000000000000000000000000000123456789012345678901234567890
val d2 = 1234567890123456789012345678900000000000000000000000000000000000000000000.0
val d3 = 1234567890.1234567890123456789
val d4 = 4.34e-05
val d5 = 5.6e-07
println(d1.toPlainString())
println(d2.toPlainString())
println(d3.toPlainString())
println(d4.toPlainString())
println(d5.toPlainString())
var list = new List<Person>();
list.Add(new Person(25, "Tom"));
list.Add(new Person(25, "Dave"));
list.Add(new Person(20, "Kate"));
list.Add(new Person(20, "Alice"));
// will produce: Alice, Kate, Dave, Tom
var sortedList = list
.OrderBy(person => person.Age)
.ThenBy(person => person.Name)
.ToList();
Javaのコードから考えるとKotlinでももちろんシンプルな記述となります。
val sortedList = list
.sortedWith(compareBy({ it.age }, { it.name }))
val sortedList = list
.sortedWith(compareBy(Person::age, Person::name))