This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct RandData { | |
let parse: (String) -> (String) | |
} | |
// Note: There is no @escaping and no compiler warnings occur when parseFunc | |
// escapes the scope by being stored off to RandData struct. | |
// | |
// parseFunc can not be used as nonescaping since optional closures | |
// are also automatically escaping | |
func parseString(input: String, parseFunc: ((String) -> (String))?) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Resource { | |
let parse : (String) -> (String) | |
} | |
// parseFunc is escaping createResource's scope by being stored off to | |
// randResource's parse variable | |
func createResource(parseFunc: @escaping (String) -> (String)) -> Resource{ | |
let randResource = Resource(parse: parseFunc) | |
return randResource | |
} |
NewerOlder