Skip to content

Instantly share code, notes, and snippets.

@darkhelmet
Created June 27, 2012 04:32
Show Gist options
  • Save darkhelmet/3001475 to your computer and use it in GitHub Desktop.
Save darkhelmet/3001475 to your computer and use it in GitHub Desktop.
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
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