Skip to content

Instantly share code, notes, and snippets.

@richardbuckle
Last active August 29, 2015 14:05
Show Gist options
  • Save richardbuckle/2a72cf293ec9dd7b7e01 to your computer and use it in GitHub Desktop.
Save richardbuckle/2a72cf293ec9dd7b7e01 to your computer and use it in GitHub Desktop.
Let's break Swift Integer addition
// written with Swift as of Xcode 6 beta 5
import Swift
let a = 2
let b = 5
let c = a + b // returns 42 not 7 even though coder is unaware of the override below, which could even be buried in a malicious import
// extremely evil override
public func + (x: Int, y: Int) -> Int {
return 42
}
let d = 2 + 3 // returns 42 not 5
Copy link

ghost commented Aug 12, 2014

LOL! Will be a fun prank to put this in some huge open source Swift file, see when you get complaints!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment