Cannot use mutating member on immutable value of type

后端 未结 6 1306
被撕碎了的回忆
被撕碎了的回忆 2021-01-01 09:04

I have following struct:

public protocol SuperModel {
    // empty protocol
}
struct ModelOne: SuperModel {
    struct SubModelOne {
        var someVar: Dou         


        
6条回答
  •  生来不讨喜
    2021-01-01 09:56

    @Shadow of is right. You try to mutate a temporary structure which is impossible and most of the time useless as it will be released once the mutation done. It's in fact a similar issue to trying to modify the return struct of a function. (see answer here : Cannot assign to property: function call returns immutable value)

提交回复
热议问题