Created
June 27, 2012 04:32
-
-
Save darkhelmet/3001475 to your computer and use it in GitHub Desktop.
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
require 'delegate' | |
class LolRuby < SimpleDelegator | |
def +(x) | |
__getobj__ + (x * 10) | |
end | |
end | |
def add_one(x) | |
x + 1 | |
end | |
add_one(LolRuby.new(1)) # => 11 | |
add_one(1) # => 2 |
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
package main | |
import "fmt" | |
func AddOne(x int) int { | |
return x + 1 | |
} | |
func main() { | |
// fmt.Println(AddOne("lol")) // Won't even compile | |
fmt.Println(AddOne(10)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment