When do I put property initialization logic into a...
# codingconventions
f
When do I put property initialization logic into an init block vs into a function? I suppose it depends on if I need the same logic again after initialization
m
If the function will return the same value for the lifetime of the object, then it can be done in the init, so it's clear, and doesn't get recomputed every time the get is called. If the state is mutable, then you'd want a function to get the latest value. One of the many reasons aiming for immutability makes a lot of code simpler.
f
thank you for the clarification!