[swift-users] adopting RandomAccessCollection protocol

2017-03-12 Thread Don Giovanni via swift-users
public class Container2: RandomAccessCollection { public typealias Indices = DefaultRandomAccessIndices; public typealias Index = Int; //typealias SubSequence = Container2; public var arr:[Int] = [1,2,3,4,5]; public var endIndex: Index { return 5; } public var startIndex:Index{ return 0;

[swift-users] adopting RandomAccessCollection protocol

2017-03-12 Thread Don Giovanni via swift-users
I'm trying to adopt the RandomAccessCollection protocol from a class. I deliberately leave out the func index(before:) function because there is already a default implementation of that function in RandomAccessCollection. I do understand that that function's implementation is required because

Re: [swift-users] adopting RandomAccessCollection protocol

2017-03-12 Thread Ole Begemann via swift-users
On 12/03/2017 16:58, Don Giovanni via swift-users wrote: I'm trying to adopt the RandomAccessCollection protocol from a class. I deliberately leave out the func index(before:) function because there is already a default implementation of that function in RandomAccessCollection. I do understand

Re: [swift-users] OptionSet as Sequence

2017-03-12 Thread Zhao Xin via swift-users
I don't see the needs to call `for domain in domains` with `domains:OptionSet`. If a parameter want an OptionSet, why not just use`domains` directly instead of `domain`? Zhaoxin On Mon, Mar 13, 2017 at 12:09 AM, J.E. Schotsman via swift-users < swift-users@swift.org> wrote: > Hello, > >

[swift-users] OptionSet as Sequence

2017-03-12 Thread J.E. Schotsman via swift-users
Hello, Recently I wrote code like this: let domains:[FileManager.SearchPathDomainMask] = [.userDomainMask, .localDomainMask, .networkDomainMask] for domain in domains { … } But I would prefer this: let domains:FileManager.SearchPathDomainMask = [.userDomainMask,.localDomainMask,

[swift-users] How to pass a protocol as parameter, without using @objc?

2017-03-12 Thread Bruno Macabeus via swift-users
Hello, I wrote a gist to list all classes that subscribers a protocol: https://gist.github.com/brunomacabeusbr/eea343bb9119b96eed3393e41dcda0c9 It work, but, I could not pass a protocol as parameter, then, I need wrote one function each time I need to list class from different protocol. I know

Re: [swift-users] (no subject)

2017-03-12 Thread Austin Zheng via swift-users
The source code on GitHub _is_ full and complete. Check out https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift#L1336-L1338 for the implementation of `count`.

[swift-users] (no subject)

2017-03-12 Thread Don Giovanni via swift-users
I understand swift is open source. However, i can't seem to find the complete source code in GitHub. For example, RandomAccessCollection protocol has a property count default implementation but upon looking through the source provided in