The notion of "return X if Y" is fun...it means I'm waking up to SNOBOL in
2018. Fantastic flashback but awkward here.
Changing formatting to allow single line "if X { trivial Y }" seems natural.
On Sat, Feb 17, 2018 at 6:05 AM, <[email protected]> wrote:
> The OP's idea is the best one so far. What about the following.
>
> r, err := os.Open("blah.txt")
> *return* nil *if* r == nil, err *if* err != nil
>
> basically every return field could be followed by an optional if clause
> with an expression that must evaluate to bool.
>
> The return only happens if all optional if clauses evaluate to true.
>
> Could be also used to bubble errors up the stack
>
> r, err := os.Open("blah.txt")
> *return* nil, fmt.Errorf("File open failed") *if* err != nil
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
Michael T. Jones
[email protected]
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.