diff options
| author | Christine Dodrill <me@christine.website> | 2018-12-03 17:44:13 -0800 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-12-03 17:44:55 -0800 |
| commit | 4d3aeafa9a22dd1e29371270995f82bc5ddcc5ce (patch) | |
| tree | f2730f38cd8193930cdb3dbe695357051f2f3ea7 | |
| parent | 0182c05788118d727d029181141e90175116e9a4 (diff) | |
| download | xesite-4d3aeafa9a22dd1e29371270995f82bc5ddcc5ce.tar.xz xesite-4d3aeafa9a22dd1e29371270995f82bc5ddcc5ce.zip | |
heh
| -rw-r--r-- | blog/go-interfaces-considered-harmful-2018-12-03.markdown | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/blog/go-interfaces-considered-harmful-2018-12-03.markdown b/blog/go-interfaces-considered-harmful-2018-12-03.markdown index 387046b..d2e7ecb 100644 --- a/blog/go-interfaces-considered-harmful-2018-12-03.markdown +++ b/blog/go-interfaces-considered-harmful-2018-12-03.markdown @@ -110,3 +110,22 @@ All of the men spoke fact about the thing, but none of them spoke the truth of w // after grope switch block log.Printf("%T", thing) // prints Elephant ``` + +--- + +``` + switch thing.(type) { + case Trunker: + log.Printf("man %d: this thing is like a thick snake", id) + case Fanner: + log.Printf("man %d: this thing is like a kind of fan", id) + case TreeTrunker: + log.Printf("man %d: this thing is like a tree trunk", id) + case Waller: + log.Printf("man %d: this thing is like a wall", id) + case Roper: + log.Printf("man %d: this thing is like a rope", id) + case Tusker: + log.Printf("man %d: this thing is hard, smooth and like a spear", id) + } +``` |
