Java のコンストラクタとかで
ふとコードを書いてて疑問に思ったことが1つ。
public ListPattern(CasePattern[] pats) { this(pats, null); } public ListPattern(CasePattern[] pats, String tail) { if (pats == null) throw new IllegalArgumentException(); this.pats = pats; this.tail = tail; }
と
public ListPattern(CasePattern[] pats) { if (pats == null) throw new IllegalArgumentException(); this.pats = pats; this.tail = null; } public ListPattern(CasePattern[] pats, String tail) { if (pats == null || tail == null) throw new IllegalArgumentException(); this.pats = pats; this.tail = tail; }
って、どっちのほうが正しい設計なのかな?