Re: [go-nuts] How to init a global map

2016-06-24 Thread Tong Sun
) >> >> Does it means the map values can be changed inside the function? >> >> If yes, what's the proper way to declare it so as to make sure the values >> cannot be changed inside the function? >> >> Thanks, and sorry if the question seems too dumb. >>

Re: [go-nuts] How to init a global map

2016-06-24 Thread Val
y to declare it so as to make sure the values > cannot be changed inside the function? > > Thanks, and sorry if the question seems too dumb. > > > ---------- Forwarded message -- > From: Valentin Deleplace @gmail.com > Date: Fri, Jun 24, 2016 at 2:11 AM > Subject: Re

Re: [go-nuts] How to init a global map

2016-06-23 Thread Tamás Gulácsi
No penalty - a map is already a pointer. -- 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:/

Re: [go-nuts] How to init a global map

2016-06-23 Thread Tong Sun
On Thu, Jun 23, 2016 at 6:54 PM, Val wrote: Even in OO style (e.g. java), you would not be able to write > Set s = null; > s.init( list(1,2,3) ); > > This is (more or less) the same problem with value receiver... the > "constructor-like" idiom in go is a function NewSet, not a method : https:

Re: [go-nuts] How to init a global map

2016-06-23 Thread andrey mirtchovski
line 17 can become: *s = make(set, len(slice)) -- 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, v

Re: [go-nuts] How to init a global map

2016-06-23 Thread Tong Sun
wow, that way. Thanks! On Thu, Jun 23, 2016 at 6:28 PM, Val wrote: > https://play.golang.org/p/DTtGs3FiwZ > > -- > You received this message because you are subscribed to a topic in the > Google Groups "golang-nuts" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/top

Re: [go-nuts] How to init a global map

2016-06-23 Thread Val
https://play.golang.org/p/DTtGs3FiwZ -- 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://gro

Re: [go-nuts] How to init a global map

2016-06-23 Thread Tong Sun
I did tried to change to, func (s *set) Init(slice []string) { but that gave loads of errors that I can't fix, hence the question. On Thu, Jun 23, 2016 at 6:19 PM, Val wrote: > Assigning a value to the receiver will only affect local variable. > Try pointer receiver. > > -- > You received thi