News for hackers. Stuff that matters.
Re:Why Swift Guard Should Be Avoided by alexjarvis on Saturday January 02, 2016 @06:18AM (#10825857)
I agree that you can split validation parts into separate functions but this is conflating two concerns, for example the rewriting of the guard statement from

  guard item.count > 0 else {
    throw VendingMachineError.OutOfStock
  }
to

  if count == 0 {
    throw VendingMachineError.OutOfStock
  }
only proves that you can refactor the code to not use guard whereas the article starts by talking about small functions, where you could in fact still use guard in this case.
Re:Why Swift Guard Should Be Avoided by rimantas on Saturday January 02, 2016 @06:21AM (#10825865)
Yes. And if all your code is composed of three-lines methods, then ok. Otherwise guard is extremely usefull, because unlike 'if' it leaves your constant/variable accessible outside the guard scope.