While it's similar to try-catch, collect is a lot more explicit as to what is going on. I'll admit that it's the least favorite of the 3 I showed, though.
When I say it's more explicit, I mean that in a typical try-catch, there's absolutely no indication as to where the error came from. This at least shows which places the error could have came from. Again, it's not my favorite thing in the world, but I'm not entirely against it
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
While it's similar to try-catch,
collect
is a lot more explicit as to what is going on. I'll admit that it's the least favorite of the 3 I showed, though.can you elaborate on how it is more explicit? it is really stopping execution of collected code block and jumps to if err != nil block?
edit:
looks like it is,
Whenever _! is assigned to, an implicit nil check is performed, and if _! is not nil, the block ceases execution.
from original proposal desription
doesnt look differrnt from throw-catch like semantics of other languages
When I say it's more explicit, I mean that in a typical try-catch, there's absolutely no indication as to where the error came from. This at least shows which places the error could have came from. Again, it's not my favorite thing in the world, but I'm not entirely against it