top | item 10275145

(no title)

solomone | 10 years ago

I wouldn't call that a bug. That's like saying you can't do

  let a = Foo()
  a.addItem(i)

discuss

order

seivan|10 years ago

It's a bug in a sense that NSArray, NSSet, NSDictionary (The mutable ones) should have the keywords setup when they are ported with Swift headers.

Naturally, that would be manual work though. Like the way they added nonnull, nilable or whatever its called to Obj-C

mikeash|10 years ago

Why would they have keywords added? Adding `mutating` to a func in a class is invalid, because the very concept makes no sense. The `mutating` keyword can only apply to value types, because it means "this func mutates the value in-place, so it needs mutable storage to invoke it."

The "bug," if there can be said to be one at all (I don't see it), is that Swift collection types are value types, while Objective-C collection types are reference types. But given this difference, the lack of `mutating` on the mutating methods makes complete sense, and adding it would be bizarre, since it would be an error if you did it in your own code.