ugh i just got bit by the difference between `val...
# announcements
s
ugh i just got bit by the difference between
val X = blah()
and
Copy code
val X
  get() = blah()
😐 2
n
@skennedy : Can u explain a bit?
s
the former calls
blah()
when the object is instantiated, the latter calls
blah()
every time you access the property
n
Ouch !!
t
I tend to avoid synthetic properties for this exact reason.
c
I would expect that though? although the usual preventative is ugly (that you see in swift too) of having a _ prefixed backing var…
t
yea it is expected, but prone to human error. thus my avoidance