Awesome, that makes so much sense. Thanks for explaining it and your help!

On Monday, March 5, 2018 at 4:03:33 PM UTC-7, Ignacio Gómez wrote:
>
> Hi, Ashish.
>
> If you have a map[string]int (or int 64, float 64, etc.) "m", doing
>
> m[key] += value
>
>
> is equivalent to this:
>
> m[key] = m[key] + value.
>
>
> Thus, on each iteration we sum the value at dataarray[j][1] (which you 
> stored at sumFloat) to the current value of sums[dataarray[j][0]] (on first 
> iteration, it just gets initialized to the zero value, in this case 0.0) in 
> order to sum values among the same letter, which are used as keys for the 
> map. So, in short, yes, that's accurate. Take a look at this to get some 
> more info on maps: https://blog.golang.org/go-maps-in-action
>
> El lunes, 5 de marzo de 2018, 18:35:11 (UTC-3), Ashish Timilsina escribió:
>>
>> Hi Ignacio,
>>
>> This is excellent, works perfectly. Thank you so much. 
>> I will try to do my research but just out of curiosity and make sure I 
>> understand the code, what does this line do? I also don't have proper 
>> understanding of golang maps 
>> sums[dataarray[j][0]] += sumFloat
>>
>>
>> So 'sum' map is taking the first index in dataarray as key, summing the 
>> second index and assigning it as the value to the key. As it is looping 
>> through the array, if it sees that the key is the same, it automatically 
>> sums it up? Is that accurate?
>>
>

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