Last active
August 29, 2015 14:05
-
-
Save richardbuckle/2a72cf293ec9dd7b7e01 to your computer and use it in GitHub Desktop.
Let's break Swift Integer addition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LOL! Will be a fun prank to put this in some huge open source Swift file, see when you get complaints!