Swift 2.0 beta: are protocols kinda broken in Xcode beta 5? -


currently i'm working on new app written swift 2.0. today faced 2 strange errors in xcode beta 5. i'd love if previous beta version of xcode can confirm if i'm right or not. misunderstand something, i'll appreciate feedback.

here example code made me struggle while:

// frist bug protocol someprotocol {      var somearray: [string] { set } // #1 bug }  extension someprotocol {      func somefunction(somestring: string) {          self.somearray.append(somestring) // #1: immutable value of type '[string]' has mutating members named 'append'     } }  // second bug protocol someinterfaceprotocol {      var somebool: bool { set } // #2 bug }  class someclass: someinterfaceprotocol {      var somebool: bool = false      func returninterface() -> someinterfaceprotocol {          return self     } }  let someinstance = someclass()  // can't set value someinstance.returninterface().somebool = true // #2: cannot assign property: function call returns immutable value 

the first error can solved if add modifier mutating before extension func declaration this:

mutating func somefunction(somestring: string) { 

i suspect that's change in language.

the other 1 puzzles me well. @ least, here's work-around:

var c = someinstance.returninterface() c.somebool = true 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -