All challenges
Code AnalysisBeginner 60s

LSP: equals/hashCode mismatch

class Point { constructor(public x:number, public y:number){} equals(o: Point) { return o.x===this.x && o.y===this.y; } } class ColorPoint extends Point { equals(o: Point) { return o instanceof ColorPoint && super.equals(o); } } const s = new Set(); s.add(new Point(1,1)); // set.has(new ColorPoint(1,1, 'red')) -> false What contract problem does this show?

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle