Xe
Go Interfaces Considered Harmful - Christine Dodrill

oh fuck

Christine Dodrill - Blog - Contact - Resume A group of blind men heard that a strange animal had been brought to the town function, but none of them were aware of its type. package blindmen type Animal interface{} func Town(strangeAnimal Animal) { Out of curiosity, they said: “We must inspect and know it by type switches and touch, of which we are capable”. type Toucher interface { Touch() interface{} } So, they sought it out, and when they found it they groped about it. for man := range make([]struct{}, 6) { go grope(man, strangeAnimal.(Toucher).Touch()) } In the case of the first person, whose hand landed on the trunk, said “This being is like a thick snake”. type Snaker interface { Snake() } func grope(id int, thing interface{}) { switch thing.(type) { case Snaker: log.Printf("man %d: this thing is like a thick snake", id) For another one whose hand ...

Linked on 2018-12-04 02:22:59 | Similar Links