Skip to content

Instantly share code, notes, and snippets.

@thomaswhitcomb
Created February 20, 2014 17:56
Show Gist options
  • Save thomaswhitcomb/9119570 to your computer and use it in GitHub Desktop.
Save thomaswhitcomb/9119570 to your computer and use it in GitHub Desktop.
Data hiding - the integer can only be modified/accessed through the get/set functions.
type obj_interface struct{
set func(y int)
get func() int
}
func instantiate() *obj_interface {
var x int
var o = new(obj_interface)
o.set = func(y int){
x = y
}
o.get = func() int{
return x
}
return o
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment