Skip to content

Commit 5ade1d2

Browse files
authored
Merge pull request #955 from moiseev/integer-compat
Arithmetic methods for Swift 3 compatibility
2 parents 015ded4 + babecb2 commit 5ade1d2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Foundation/NSDecimal.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,32 @@ extension Decimal : SignedNumeric {
340340
}
341341
}
342342

343+
extension Decimal {
344+
@available(swift, obsoleted: 4, message: "Please use arithmetic operators instead")
345+
@_transparent
346+
public mutating func add(_ other: Decimal) {
347+
self += other
348+
}
349+
350+
@available(swift, obsoleted: 4, message: "Please use arithmetic operators instead")
351+
@_transparent
352+
public mutating func subtract(_ other: Decimal) {
353+
self -= other
354+
}
355+
356+
@available(swift, obsoleted: 4, message: "Please use arithmetic operators instead")
357+
@_transparent
358+
public mutating func multiply(by other: Decimal) {
359+
self *= other
360+
}
361+
362+
@available(swift, obsoleted: 4, message: "Please use arithmetic operators instead")
363+
@_transparent
364+
public mutating func divide(by other: Decimal) {
365+
self /= other
366+
}
367+
}
368+
343369
extension Decimal : Strideable {
344370
public func distance(to other: Decimal) -> Decimal {
345371
return self - other

0 commit comments

Comments
 (0)