Re: [swift-users] Implementing += for optional arrays

2016-10-20 Thread Ben Cohen via swift-users
Hi Rick, I think you’re looking for something like this? Assuming when you say “return” in your bullet spec you mean assign-in-place since we’re talking about += func +=(lhs: inout [T]?, rhs: [T]?) { switch (lhs,rhs) { case (_,nil): return // no-op whether lhs

[swift-users] Implementing += for optional arrays

2016-10-20 Thread Rick Mann via swift-users
When working with URLComponents query items, it would be nice to write code like this: var oqi: [URLQueryItem]? = [..., ..., ...] var comps = URLComponents(…) comps.queryItems += oqi The problem is that queryItems is [URLQueryItem]?, and so I can't just append. I'd like to write a version of +