Hi, In the chapter of "Method set" from "Go in Action", there is a description as below "This shows that it’s not always possible to get the address of a value.", the question is in which case does compiler not able to get the address of a value and why, thanks.
01 // Sample program to show how you can't always get the 02 // address of a value. 03 package main 04 05 import "fmt" 06 07 // duration is a type with a base type of int. 08 type duration int 09 10 // format pretty-prints the duration value. 11 func (d *duration) pretty() string { 12 return fmt.Sprintf("Duration: %d", *d) 13 } 14 15 // main is the entry point for the application. 16 func main() { 17 duration(42).pretty() 18 19 // ./listing46.go:17: cannot call pointer method on duration(42) 20 // ./listing46.go:17: cannot take the address of duration(42) 21 } -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.