by Kaylebor · 9y ago · 0 comments
Just the way it allows you to create an inmutable class in a single line already makes it way easier to read, while also saving time.
Compare Java:
public class Person {
private final String name;
private final int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
}
With Kotlin: data class Person(val name: String, val age: Int)No comments yet.