Cabus Cabus - 2 months ago 63
Swift Question

Swift 3 mutating functions missing ('...inPlace' methods)

In Swift 2.3, we can write something like this:

var rect = CGRect(...)
rect.offsetInPlace(dx: 15, dy: 0)


to move a rect 15pt to the right.

However in Swift 3, it seems like this function does no longer exist.
When inspecting the
CGRect
interface we can only see the non mutating variant
offsetBy(dx:, dy:)
. This is also true in all the places we've usually used mutating functions (named
...inPlace
). I have already searched the Swift evolution repo on GitHub, but couldn't find any notes about this.

Have the mutating variants been removed? Is the remaining function automatically mutating depending on whether or not the return value is used? IMHO, it would be a shame, if they have actually been removed, because they used to be very convenient when doing code based layout, etc.

Answer

It seems there is no offsetInPlace anymore. Please see the screen here is all available functions in Instance Methods enter image description here

Comments