petervanhoef/Calculator

Question on a Break in CalculatorBrain.swift

Closed this issue · 1 comments

Is the break at line 63 necessary (in the mutating func performOperation)? I didn't think breaks were required when switching on Cases in Swift since they don't fall through? I commented it out on a copy that I made and it seemed to run fine, but wanted to check if there was a reason you had it in there.

With your help I feel like I now understand this first assignment, so now I am moving on to Assignment #2. Thanks again!

You are right. It is not needed there. In lecture 2, Paul Hegarty wrote a break initially as the case didn't contain a statement at all. I guess I overlooked the removal of the break.

I removed the break and, as expected, all unit tests still pass.