2 ms·
One small nit on the Go example code: func (wordTotals *WordTotals) Update(word string) { total, found := wordTotals.WordTotals[word] if !fou
by pstuart 9y ago
One small nit on the Go example code:
func (wordTotals *WordTotals) Update(word string) {
total, found := wordTotals.WordTotals[word]
if !found {
total = 0
}
wordTotals.WordTotals[word] = total + 1
}
Can be done as:
func (wordTotals *WordTotals) Update(word string) {
wordTotals.WordTotals[word] += 1
}
(thanks to Go default values)