Karlo Lozovina02/18/2022, 5:33 PM
property doesn't always return the same value? Say it has a getter, and does some computation on other mutable parts of the class. Is it horrible? Amazingly bad?
Paul Griffith02/18/2022, 5:40 PM
Karlo Lozovina02/18/2022, 5:52 PM
Klitos Kyriacou02/18/2022, 6:31 PM
properties even in the Kotlin API itself, such as
mkrussel02/18/2022, 6:41 PM
. If it is something that is calculated randomly or has side effects, then being a
would be bad.
ephemient02/20/2022, 3:20 PM
Prefer a property over a function when the underlying algorithm:
• does not throw
• is cheap to calculate (or cached on the first run)
• returns the same result over invocations if the object state hasn't changedso if it returns a different value without state changes, it's recommended not to use a