| ▲ | Lvl999Noob 2 days ago | |||||||||||||
What if Go went all the way? Referencing a zero pointer (nil) gives you the zero value of the pointed to type. If you try to access a zero map, it tries to deference the zero pointer to the underlying buffer. The zero pointer gives you the zero slice with zero length. The presence check fails without crashing and you get some pretension of reasonable behaviour. | ||||||||||||||
| ▲ | 2 days ago | parent | next [-] | |||||||||||||
| [deleted] | ||||||||||||||
| ▲ | ptman 2 days ago | parent | prev [-] | |||||||||||||
So what happens when you write through the nil pointer? | ||||||||||||||
| ||||||||||||||