Maybe ???
In a case where there is a function taking parameters from an optional value that is then doing internal checks for optionality and then return nil itself, why not do some sort of soft unwrap with a postfix operator (or something). Something like "unwrap or return nil".
In a place where it would be
parameter: if let myStruct { foo(myStruct.propA, myStruct.propB) } else { nil }
it could be
parameter: myStruct ??? foo(myStruct.propA, myStruct.propB) }
I can't think of a way where the signature could stay as this
parameter: if let myStruct { foo(myStruct?.propA, myStruct?.propB) } else { nil }
but somehow let that function immediately return nil if myStruct is nil
Maybe a wrapper that modifies a parameter or parameter type?
Similar but nicer than myStruct != nil ? foo(myStruct!.propA, myStruct!.propB) : nil
Maybe ???
In a case where there is a function taking parameters from an optional value that is then doing internal checks for optionality and then return nil itself, why not do some sort of soft unwrap with a postfix operator (or something). Something like "unwrap or return nil".
In a place where it would be
parameter: if let myStruct { foo(myStruct.propA, myStruct.propB) } else { nil }
it could be
parameter: myStruct ??? foo(myStruct.propA, myStruct.propB) }
I can't think of a way where the signature could stay as this
parameter: if let myStruct { foo(myStruct?.propA, myStruct?.propB) } else { nil }
but somehow let that function immediately return nil if myStruct is nil
Maybe a wrapper that modifies a parameter or parameter type?
Similar but nicer than myStruct != nil ? foo(myStruct!.propA, myStruct!.propB) : nil