|
YardVox |
at Feb 2, 2013 at 10:22 pm
|
⇧ |
| |
Thank you Peter and Ian for taking time from your weekend to explain the
workings of Go
Postmortem lessons learned:
1) Go is not C ... like C .. but not C
2) If you import fmt then "Closely read about the functions you call". In
this case Sprintf and Println.
The Package Doc for fmt.Println is:
func Println(a ...interface{}) (n int, err error)
There it is. a...interface{}. This is not a static type.
type Force string // is a static type (least a non-interface-type) but
when you pass it to fmt.Println it becomes dynamic
and seeing the .String() recursion ... it is interface{} all the way down.
So when a Go func has a...interface{} as the argument ... Type processing
occurs when a Type is passed to the function.
In this case import fmt got me the Stringer interface and
when I defined a String() func for type Force I told Go that every time
the Stringer interface is caledl handle zforce.String() if called.
On Saturday, February 2, 2013 7:42:36 AM UTC-5, YardVox wrote:String() GotCha please explain to a tired old mind
The linked code below runs as is but
reverse comment the type, return and assignment statements
and this program runs out of memory and produces the error:
throw: out of memory (FixAlloc)
http://play.golang.org/p/7GiWcDgqHe --
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+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out.