I have a lazy var in my struct called labelColors:
lazy var _labelColors: LabelType = { return url.getTagColors() }()
var labelColors : LabelType {
mutating get { return _labelColors }
set { _labelColors = newValue }
}
It should only call its value, when it is really needed the first time. When using a filter on my huge array, I have
let redFilesOnly = files.filter({ $0.labelColors.isColorSet(color: TagColors.red) })
But error is "Cannot use mutating getter on immutable value: '$0' is immutable". But how can I use a getter function, which is defined as lazy, so it will be changing its value?