Today is Day 4 of my #30DaysOfCode challenge. I started my day with learning maps in Go and then moved to play with pointers a little. So, let's talk about them one by one.
What are Maps?
Maps are a data structure in Go which stores collections of data in key-value pair. If you have worked with programming languages like Python or Swift then you are very familiar with maps. Python and Swift have a data structure called Dictionary which is just like Maps. They are essentially just the same thing but with a different name. They store data in a key-value pair. We will talk more about Maps in the next post, follow me for that.
Now, as promised in the last post, here I am with a simple little example of pointers in #golang. So, let's take a look at the example of a pointer. We use & and * to work with pointers. The & gives us the address of the value in the memory location and * gives us the value of the address that is passed in. Take a look at the example in the image to get a higher-level understanding of pointers and if you have any question then feel free to ask me in the comments below.
BTW, I am sorry for this cryptic explanation but this is how it's work and I don't expect anyone to understand pointers the first time they see it. It's a very confusing topic and it takes lots of practice to get a hang of it. But I promise that I will try to make it simpler next time.
One thing that is interesting to know is that pointer is not a feature that is very specific to Go but it also has its place in programming languages like C and C++.
Alright! that's all for today and I'll see you in the next post.