diff --git a/ExSwift/Array.swift b/ExSwift/Array.swift index 80287d5..cc32468 100644 --- a/ExSwift/Array.swift +++ b/ExSwift/Array.swift @@ -1361,6 +1361,13 @@ internal extension Array { } +/** + Push an element to the array +*/ +public func += (inout first: [T], second: T) { + first.append(second) +} + /** Remove an element from the array */ diff --git a/ExSwiftTests/ArrayExtensionsTests.swift b/ExSwiftTests/ArrayExtensionsTests.swift index 8a50b22..1b30ddd 100644 --- a/ExSwiftTests/ArrayExtensionsTests.swift +++ b/ExSwiftTests/ArrayExtensionsTests.swift @@ -516,6 +516,13 @@ class ArrayExtensionsSpec: QuickSpec { } + it("operator") { + + self.intArray += 20 + + expect(self.intArray.last) == 20 + } + } /** diff --git a/README.md b/README.md index c5d5604..1a33f73 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,7 @@ Name | Signatures #### Operators #### Name | Signature | Function ---- | --------- | -------- +`+=`|`+= (first: T, second: Array)`|Push `-`|`- (first: Array, second: Array) -> Array`|Difference `-`|`- (first: Array, second: T) -> Array`|Element removal `&`|`& (first: Array, second: Array) -> Array`|Intersection