Compare https://bugs.swift.org/browse/SR-1570 : Swift can infer the return
type from single-statement closures, but not from multi-statement closures.
Therefore in
let result = strArr.flatMap { x in
return x
}
the closure type is inferred as (String)-> String, and therefore th
On 21.10.17 02:50, Santiago Gil via swift-users wrote:
I just ran into a bug after a Swift 4 migration where we expected
[String] and got [Character] from a flatMap since flatMap will flatten
the String since it's now a collection. While I understand why
flatMap behaves this way now that strin
Oops! forgot to add example code for resetting with non-optional public var :
public struct TestStruct
{
private var _description: String?
public var description: String
{
get
{
return _description ?? ""
}
set
{
_description = newValue
}
}
mutati
> It just seems so obvious to create-if-nil, and makes it nice to reset stuff
> that should be re-created. In my case, after my NSURLSession gets
> invalidated, I wanted to set the property to nil, and next time a session was
> needed, it would just get created.
The only thing I would query wit