Skip to content

Instantly share code, notes, and snippets.

@kongtomorrow
Created July 17, 2014 02:04
Show Gist options
  • Save kongtomorrow/f8d4a485ca4ff53ee728 to your computer and use it in GitHub Desktop.
Save kongtomorrow/f8d4a485ca4ff53ee728 to your computer and use it in GitHub Desktop.
sekret protocol requirements!
class FooColl : Swift.Collection {
/* Secret protocol conformance requirements! Apparently Collection
inherits from a "_Collection" protocol that has more stuff.
error: type 'FooColl' does not conform to protocol '_Collection'
class FooColl : Swift.Collection {
^
Swift._Collection:3:19: note: protocol requires property 'startIndex' with type 'FooColl.IndexType'
/*@public*/ var startIndex: IndexType { get }
^
Swift._Collection:4:19: note: protocol requires property 'endIndex' with type 'FooColl.IndexType'
/*@public*/ var endIndex: IndexType { get }
^
*/
// var startIndex : Int { get { return 2 } }
// var endIndex : Int { get { return 9 } }
func generate() -> GeneratorOf<Int> {
var i = 2
return GeneratorOf<Int> {
if i < 10 {
return i
} else {
return nil
}
}
}
subscript (i: Int) -> Int {
get{
return 0
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment