wow, super impressed!
On Thursday, October 19, 2017 at 10:22:26 AM UTC-7, rog wrote:
>
> Or taking it a bit further: https://play.golang.org/p/g4uF2QjiJQ
>
>
> On 18 October 2017 at 23:38, Alex Dvoretskiy > wrote:
> > Looks fun!: https://play.golang.org/p/8mqzb-1H7f
> >
Or taking it a bit further: https://play.golang.org/p/g4uF2QjiJQ
On 18 October 2017 at 23:38, Alex Dvoretskiy wrote:
> 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
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] =
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
A nil map is like a regular map but it has nothing in it, cannot grow, and
takes zero space.
-rob
On Tue, Oct 17, 2017 at 5:31 PM, Christian Himpel
wrote:
> The spec defines: "A nil map is equivalent to an empty map except that no
> elements may be added."
The spec defines: "A nil map is equivalent to an empty map except that no
elements may be added." https://golang.org/ref/spec#Map_types
You could return a nil map, if you have no elements to add, and a caller
would just need to read.
On Tue, Oct 17, 2017 at 7:02 AM Dan Kortschak
If you only need the map conditionally, you need to declare it and then
conditionally make it.
```
var m map[string]int
if needMap {
m = make(map[string]int)
}
```
On Mon, 2017-10-16 at 21:52 -0700, Alex Dvoretskiy wrote:
> Hello, Golang Nuts!
>
> I have an interesting question about maps.
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?