On Sunday, January 9, 2022 at 3:07:18 PM UTC-8 bse...@computer.org wrote:

> Note that a with a map[string]string, the code:
>
> m[s]=s
>
> The contents of the string s are not duplicated, only the string header s 
> is. 
>

I didn't know this. That's very good to know.

What about this:

package main

type word struct {
  s string
  refcnt int
}

var w1 = word {"moby", 1}

func main() {
        m := make(map[string]word)
        m["moby"] = w1
}

This is a little closer to what I'd like to do.
How many times would the string "moby" be stored?

Thanks,
Jon

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6f06bbe8-8d50-46f6-8b28-f4e680ecae43n%40googlegroups.com.

Reply via email to