Looks fun!: https://play.golang.org/p/8mqzb-1H7f

On Tuesday, October 17, 2017 at 10:39:46 AM UTC-7, Thomas Bushnell, BSG 
wrote:
>
> Here's a case that comes up for me:
>
> type table map[string]map[string]string
>
> func (t table) add(x, y, z string) {
>   if t[x] == nil {
>     t[x] = make(map[string]string)
>   }
>   t[x][y] = z
> }
>
> func (t table) get(x, y string) string {
>   return t[x][y]
> }
>
> The fact that t[x] can be indexed even if it hasn't been created makes 
> this much simpler.
>
> On Tue, Oct 17, 2017 at 12:52 AM Alex Dvoretskiy <advore...@gmail.com 
> <javascript:>> wrote:
>
>> Hello, Golang Nuts!
>>
>> I have an interesting question about maps. What is the possible usage of 
>> nil maps, which can be declared like "var m map[string]int"? You can't 
>> write to nil map but have an option to create it.
>>
>> Perhaps there is no use at all and this is just language specific feature?
>>
>> Thank you.
>>
>> -- 
>> 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 <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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.

Reply via email to