Michael Böiers
04/19/2021, 4:39 PMfun parsedElements()
b) Define a function naming the data returned prefixed with get (since as per coding conventions functions should incorporate a verb): fun getParsedElements()
c) Define a read-only property naming the data returned: val parsedElements: List<String> get() = …
What’s considered best practice, does it depend on “how dynamic” the code is?nanodeath
04/19/2021, 4:47 PMfun
if you want the caller to treat it as a calculation, val if it's cheap and likely to be used (and immutable), val get if it's cheap and might be used, and val lazy if it's expensive (and immutable)Michael Böiers
04/19/2021, 4:49 PMnanodeath
04/19/2021, 5:04 PMMichael Böiers
04/19/2021, 5:04 PMgeepawhill
04/19/2021, 5:06 PMMichael Böiers
04/19/2021, 5:21 PMval computeHeight
nanodeath
04/19/2021, 5:29 PMMichael Böiers
04/19/2021, 5:39 PMfun derivedHeight()
)