DRYな備忘録

Don't Repeat Yourself.

interface

TypeScriptのinterface制限のextendsと、ついでにダックタイピングのメモ

問題 interfaceってextendsできるんだっけ? メソッドとプロパティさえ満たしてれば型制約突破できるんだっけ?(ダックタイピング) メモ interface Speaker { Speak(s: string): void; } interface Person extends Speaker { name: string; Greet(): void;…

Go言語でinterfaceをimpleしてるつもりが「does not implement (method has pointer receiver)」って叱られる【golang】【pointer】【ダックタイピング】

問題 Go言語はinterfaceによる型の制約ができる。逆にinterfaceで宣言したメソッドをすべて満たすいかなるstructもそのinterfaceを満たすものとして扱える。いわゆるダックタイピング。 参考 ダックタイピングって一体なんなのよ【golang】 - DRYな備忘録 で…