これは私のコードから取り除かれたサンプルです:
struct Widget {
let string: String
init(_ string: String) throws {
self.string = string
}
}
struct Widgets {
let widgets: [Widget]
init(_ strings: [String]) throws {
// Is this really the cleanest way to do the map?
widgets = try strings.map({(string:String) throws -> Widget in
return try Widget(string)
})
}
}