[swift-users] Fwd: Workaround for generics not currently supporting conditional conformance to a protocol

2016-11-15 Thread Howard Lovatt via swift-users
@Dave, How do I write that though. I can't write: extension Array: Equatable { static func ==(lhs: Array, rhs: Array) -> Bool { let size = lhs.count precondition(rhs.count == size, "The arrays must be the same length") for i in 0 ..< size {

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Игорь Никитин via swift-users
And, as I know, it's not possible to call protocol's implementation in that case > 16 нояб. 2016 г., в 4:29, Rick Mann via swift-users > написал(а): > > Okay. I coudln't find official documentation on this, and I don't currently > need to do this, but wanted to fully

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Игорь Никитин via swift-users
And, as I know, it's not possible to call protocol's implementation in that case > 16 нояб. 2016 г., в 9:09, Игорь Никитин via swift-users > написал(а): > > Right, it’s a recursion, because this > > (self as FooPro).fooFunc() > > Will call FooClass’s method

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Игорь Никитин via swift-users
Right, it’s a recursion, because this (self as FooPro).fooFunc() Will call FooClass’s method implementation You can read more about dispatch rules here: https://medium.com/ios-os-x-development/swift-protocol-extension-method-dispatch-6a6bf270ba94#.hkh1rc56p

[swift-users] Workaround for generics not currently supporting conditional conformance to a protocol

2016-11-15 Thread Howard Lovatt via swift-users
Hi All, Does anyone have a good workaround for generics not currently supporting conditional conformance to a protocol. As stated in the Generics Manifesto something like this would be nice: extension Array: Equatable where Element: Equatable { static func ==(lhs: Array, rhs: Array) ->

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Rick Mann via swift-users
Okay. I coudln't find official documentation on this, and I don't currently need to do this, but wanted to fully understand it. > On Nov 15, 2016, at 17:27 , zh ao wrote: > > 'Default' implementation in protocol extension is used as fail safe. You > should not consider it

Re: [swift-users] Attempting to call default protocol implementation crashes Playground

2016-11-15 Thread Rick Mann via swift-users
Well, this is a standard protocol default implementation. I was experimenting to see if it was possible to call the default implementation after providing a concrete implementation. > On Nov 15, 2016, at 14:47 , Dan Loewenherz wrote: > > What are you trying to accomplish

Re: [swift-users] Reflection in Swift 3?

2016-11-15 Thread Rick Mann via swift-users
> On Nov 15, 2016, at 05:24 , Jeremy Pereira > wrote: > > >> On 15 Nov 2016, at 10:33, Rick Mann wrote: >> >> Well, that's not really any different than a switch statement, in that it >> has to be maintained. > > Yes, but I would

Re: [swift-users] Reflection in Swift 3?

2016-11-15 Thread Jeremy Pereira via swift-users
> On 15 Nov 2016, at 10:33, Rick Mann wrote: > > Well, that's not really any different than a switch statement, in that it has > to be maintained. Yes, but I would argue that it is a good thing because you need to do some validation before you instantiate the class

Re: [swift-users] Overload Resolution of Binary Operators

2016-11-15 Thread Toni Suter via swift-users
@David If you would split up the statement like this... let x = 0 *** 4 let result = x +++ 0 ... the compiler would report an ambiguity error, because both overloads of *** are valid and of equivalent priority. You could do something like this though: let x: Int = 0 *** 4// picks f2 let