Skip to content

Instantly share code, notes, and snippets.

@mk0x9
Created December 23, 2010 20:32
Show Gist options
  • Save mk0x9/753509 to your computer and use it in GitHub Desktop.
Save mk0x9/753509 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
type foo struct {
b int
c int
}
func (foo *foo) bar(a int) int {
fmt.Println(a + foo.b)
return a * foo.c
}
func (foo *foo) init() {
foo.b = 3
foo.c = 5
}
func main() {
f := new(foo)
f.init()
f.bar(1)
}
@iorlas
Copy link

iorlas commented Dec 23, 2010

package main
import fmt
struct foo:
    b int
    c int

func *foo bar(a int) int:
    fmt.Println(a+self.b)
    return a * self.c

func main():
    f := new(foo)
    f.bar(1)

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