https://kotlinlang.org logo
#announcements
Title
# announcements
g

groostav

02/16/2017, 10:19 PM
does anybody have a good intro to properties for 100% java programmers?
m

miha-x64

02/16/2017, 10:20 PM
groostav: in Java, get/set is property interface emulation, field is property implementation
g

groostav

02/16/2017, 10:21 PM
lol, yes im well aware, I'm looking for a blog post or walk-through to explain the advantages of this strategy
s

sreich

02/16/2017, 10:22 PM
i found the docs to be pretty helpful
g

groostav

02/16/2017, 10:23 PM
their not bad, I was just looking at them, but they dont explain why kotlin has properties
s

sreich

02/16/2017, 10:23 PM
for starters, many modern languages do and that's a bit expected
i would've thought the reason was clear though? you can do a lot of nice things concisely, caching and things
and java always had a ton of boilerplate for simply writing their own limited "properties"
g

groostav

02/16/2017, 10:24 PM
I just had a kotlin-newbie pull request a change
Copy code
class Thingy{
  var property: Model
    private set;
}
to
Copy code
class Thingy{
  var property: Model
    private set;

  fun updateProperty(newModel: Model) {
    property = newModel
  }
}
because he didn't understand what
two methods have the same JVM signature
meant as an error message when he tried to call it
fun setPropety
🙃 2
m

miha-x64

02/16/2017, 10:24 PM
why
Many things IDE generates for Java (Constructors, Getters and Setters) can be just written in Kotlin, that's why 🙂
g

groostav

02/16/2017, 10:25 PM
so what i want to do is give this kotlin newbie something to read
what would you guys suggest?
s

sreich

02/16/2017, 10:26 PM
that particular thing sounds like a spot the compiler could be more helpful at, as a side note 😉
if there isn't one, maybe you should file a youtrack issue
3 Views