I have the following struct:
struct MyStruct {
var myInt: Int
var myString: String
}
This struct should be edited in a function like this:
func editMyStruct(action: (inout MyStruct) -> ()) {
var mutableMyStruct = MyStruct(myInt: 10, myString: "Foo")
action(&mutableMyStruct)
//do something with the modified 'mutableMyStruct' ...
}
However, I do have difficulties to call editMyStruct(action: (inout MyStruct) -> ())
.
editMyStruct(action: { myStruct in
myStruct.myInt = 20
myStruct.myString = "Bar"
})
XCode throws the error:
Type of expression is ambiguous without more context
Does anyone of you know, how to fix this issue?
Looking forward to your response!