Hi folks,In below code, I am invoking receiver api show() via a simple uInteger type variable instead of pointer, by which it expects to be invoked . Go being strict with type casing and I was expecting a compiler error. But to my surprise, it compiled and executed successfully. Can you folks please explain this behavior.package main
import "fmt"
type uInteger int
func main() {
var x uInteger = 10
x.show()
}
func (x *uInteger) show() {
fmt.Printf("In show, x = %d\n", *x)
}Thanks in Advance,Venkatesh
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAJr0cerqTGvQA56yQWVYW3F2Ms5vbwq3YyO%2But%3DzJ%2BM4rqf81A%40mail.gmail.com.
A method call x.m() is valid if the method set of (the type of) x contains m and the argument list can be assigned to the parameter list of m. If x is addressable and &x's method set contains m, x.m() is shorthand for (&x).m():
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAMV2Rqq%2BZi7ioHi4PPXTmQ7du45LRJaEiSSWJpf1zeH%2Bq3Wjeg%40mail.gmail.com.