0X01 golang中,map(字典)无法并发读写 简单来说,新建万条线程对同一个map又读又写,会报错. 为此,最好加锁,其实性能影响并不明显. type taskCache struct{ sync.RWMutex data map[string] interface{} } 0X02 golang中,map(字典)为引用拷贝. a = 字典一 b = a 实际上是直接将指针传给了b. 于是,有一个读取,写的时候直接读map并返回 func GetAllTasks() (result ma
text = 'The rain in Spain falls mainly in the plain.'first = Hash.new []second = Hash.new {|hash,key| hash[key] = []} text.split(/\W+/).each do |word| p "word: #{word}" p first[word[0, 1].downcase].object_id first[word[0, 1].downcase] << w