Skip to content

Commit 9c38fbc

Browse files
authored
Handle nil shape in PrintProperties method
1 parent 352b4ea commit 9c38fbc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

challenge-10/submissions/0xSangeet/solution-template.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ func NewShapeCalculator() *ShapeCalculator {
9797

9898
// PrintProperties prints the properties of a shape
9999
func (sc *ShapeCalculator) PrintProperties(s Shape) {
100+
if s == nil {
101+
fmt.Println("<nil>")
102+
return
103+
}
100104
fmt.Println(s.String())
101105
}
102106

@@ -140,4 +144,4 @@ func (sc *ShapeCalculator) SortByArea(shapes []Shape, ascending bool) []Shape {
140144
return sorted[i].Area() > sorted[j].Area()
141145
})
142146
return sorted
143-
}
147+
}

0 commit comments

Comments
 (0)