@mjtsai On your latest blog post, the recommended replacement for macros is functions, so:
MJT_ENSURE(string, e, error)?.doSomething()
-
-
@roopeshchander How does that work if I'm using "string" multiple times throughout the rest of the method?0 replies 0 retweets 0 likes -
@mjtsai It doesn't :). You will have to use an `if` block in that case, I admit.0 replies 0 retweets 0 likes -
@mjtsai A minor defence: A macro with a return in it makes the code somewhat hard to read and decipher by others0 replies 0 retweets 0 likes -
@roopeshchander Yeah, some people won't like that. I think it's worth it, and it's basically the same pattern Apple's macros have long used.0 replies 0 retweets 0 likes -
@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.0 replies 0 retweets 0 likes
@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