Is it possible to Property Set to a nil value for an optional property?
LittleCodingFox opened this issue · 1 comments
LittleCodingFox commented
I'm setting a property but it seems that property.set doesn't accept nil values. In this case it's an Int?
. What would I need to do to make Runtime support this?
wickwirew commented
The problem is that the underlying value type is not known. So when you do try property.set(value: nil, on: &value)
the wrapped type in Optional<?>
is ambiguous, and not all nil
s are the same. e.g. Optional<Int64?>.none
has a different size than Optional<Int32?>
.
You could just do try property.set(value: Optional<Int>.none, on: &value)
to clear it up.