2 ms·
I was thinking about forking the language just so I could add a Maybe monad. I now typically deal with this via a Must() function that takes to values and retu
by flgr 10y ago
I was thinking about forking the language just so I could add a Maybe monad.
I now typically deal with this via a Must() function that takes to values and return the non-err value or panics if there was an err.
That means you can call it like con := Must(db.Connect(...)).(db.Connection)
- flgr 10y agoThis is not super-conventional, but some of the standard library uses panics in a similar way. I think as long as panics don't cross library boundaries you're fine. And panics can cross library functions if the function is called MustConnect(). (Which means it'd be neat to have a pre-processor that generated MustX from X if it wasn't already there...)