Extending Array from custom Sequence in Swift? -


i'm trying to:

  1. make custom protocols descended sequence , generator specialsequence , specialgenerator
  2. implement specialgenerator specialgen
  3. extend array implement specialsequence

here's i've tried far:

protocol specialgenerator: generator {     typealias t;     func next() -> t?;     //... }  class specialgen<t>: specialgenerator {     var objects: array<t>;     var currindex = 0;      init(objs: array<t>) {         self.objects = objs;     }      func next() -> t? {         return objects[currindex];     }     //... }  protocol specialsequence: sequence {     typealias t;     func generate() -> specialgenerator;     //... }  extension array: specialsequence {     func generate() -> specialgenerator {         return specialgen(objs: self);     } } 

but error array<t> not conform protocol "specialsequence"

i've tried using various combinations of specialgenerator , specialgen<t> return types no avail.

is possible in swift?

you need supply value type alias defined

protocol specialsequence: sequence {     typealias foo;     func generate() -> specialgenerator;     //... } extension array: specialsequence {     typealias foo = t     func generate() -> specialgenerator {         return specialgen(objs: self);     } } 

this compiles me


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -