You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if you've moved past this, but it looks like something to do with the @autoclosure (could be a Swift bug?). One way to get this to work is to use curly braces instead of parentheses:
extensionString{func functionThatThrows()throws{
_ =tryString(contentsOf:URL(fileURLWithPath:NSTemporaryDirectory()))}}func example(){letstrings=["Hello,","world!"]forstringin strings {letresult=Result(try string.functionThatThrows()) // works
print(result)}letresults= strings.map{ string ->Result<(),AnyError>inletresult=Result{try string.functionThatThrows()} // works
// let result = Result(try string.functionThatThrows()) // doesn't work
print(result)return result
}print(results)}
This code compiles without issue, where
generatedEvents
is of type[EKEvent]
andeventStore
is anEKEventStore
:However, when I rewrite it as a map (to generate an array of
Result
s):I receive the compiler error:
However, looking at the
Result
initializer, it looks like the error is handled in ado
/catch
block.The text was updated successfully, but these errors were encountered: