March 2019
Intermediate to advanced
336 pages
9h 9m
English
The GetValues method of the Dictionary class returns the array of the DictVal elements. In the following code snippet, the RLock method of the lock instance is invoked and the RUnlock method is deferred. The array of dictionary values is returned after traversing the element's map:
// GetValues method func (dict *Dictionary) GetValues() []DictVal { dict.lock.RLock() defer dict.lock.RUnlock() var dictValues []DictVal dictValues = []DictVal{} var key DictKey for key = range dict.elements { dictValues = append(dictValues, dict.elements[key]) } return dictValues}
Read now
Unlock full access