@mjtsai On your latest blog post, the recommended replacement for macros is functions, so:
MJT_ENSURE(string, e, error)?.doSomething()
@mjtsai I can see the value in macros like that. But I don't see a way to do that in Swift. Or rather, that doesn't fit with The Swift Way.
-
-
@mjtsai And about the adding a `!` after each variable use, have you considered implicit unwrapping? -
@roopeshchander That's discussed in the comments. -
@mjtsai Just saw that. On second thoughts, it's better NOT to use implicit unwrapping here, coz we need to check for nil. if-let is better. -
@roopeshchander Choice between compiler help with safety and avoiding extra indentation. -
@mjtsai We can't avoid the extra indentation because `if` is unavoidable, right? -
@roopeshchander Right. That's why I think there needs to be a better way to do this in Swift. -
-
@roopeshchander My main issue is that there's going to be 3+ lines of error-handling code for each line that does something that might fail. - Show more
-
-
@roopeshchander Yep. But is The Swift Way good? I’d love to see real examples of what people think is good Swift code for handling errors.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Roopesh Chander
Michael Tsai