Closed ghost closed 5 years ago
I think this might need to be re-phrased as it is both right and wrong.
“The problem is that addition only works on Int values”
Excerpt From: Chris Eidhof. “Functional Swift.” iBooks. Section: Optional binding re-visited
This might be a bit misleading, because addition is an overloaded function, so it depends where it is used. With Int's it is true
public func +(lhs: Int, rhs: Int) -> Int
but elsewhere...
public func +<RRC1 : RangeReplaceableCollection, RRC2 : RangeReplaceableCollection where RRC1.Iterator.Element == RRC2.Iterator.Element>(lhs: RRC1, rhs: RRC2) -> RRC1
let a = [1,2,3] let b = [2,3,4] let c = a + b
The book is great so far. Thanks for the effort.
I think this might need to be re-phrased as it is both right and wrong.
“The problem is that addition only works on Int values”
Excerpt From: Chris Eidhof. “Functional Swift.” iBooks. Section: Optional binding re-visited
This might be a bit misleading, because addition is an overloaded function, so it depends where it is used. With Int's it is true
public func +(lhs: Int, rhs: Int) -> Int
but elsewhere...
public func +<RRC1 : RangeReplaceableCollection, RRC2 : RangeReplaceableCollection where RRC1.Iterator.Element == RRC2.Iterator.Element>(lhs: RRC1, rhs: RRC2) -> RRC1
let a = [1,2,3] let b = [2,3,4] let c = a + b
The book is great so far. Thanks for the effort.