alickbass/CodableFirebase

default values not working if field doesn't exist.

WingYn opened this issue · 2 comments

default value ignored so that the value becomes nil instead of what is set.

struct A: Codable {
    var A: Double? = 1.0
}´´´

It is not ignored. If value is missing in Firebase, it is will be nil in the stuct, as all the properties of the struct are initialized from the Firebase. If you want to always have some value, first of all, the value should not be Optional, and secondly you have to override the Codable constructor and specify the default values there

Closing issue due to lack of activity