<FromGitter>
<cinnamonz:matrix.org> is there a pattern for using return types similar to golang where a function return would be `(T, Error?)` ? in this example `Error` is an alias for `String | Exception`.
<FromGitter>
<Blacksmoke16> not really, most cases its more idiomatic to just use exceptions
<FromGitter>
<Blacksmoke16> or nilable return types
<FromGitter>
<cinnamonz:matrix.org> hmm, like raising an exception if the nilable return is nil?
<FromGitter>
<oprypin:matrix.org> cinnamonz (https://matrix.to/#/@cinnamonz:matrix.org): Crystal is very well equipped for such a usage (String|CustomError), it's just super not idiomatic. indeed the options are String|Nil or String (+raise exception)
<FromGitter>
<oprypin:matrix.org> Go style {T|Nil, Error|String|Nil} is even more ugly, not to even be seriously considered
ur5us has quit [Ping timeout: 272 seconds]
<yxhuvud>
something like returning a Result which is then subtyped into something like SuccessResult or ErrorResult is probably not something I'd consider an antipattern though. There are cases where I'd consider such a thing, but it is definitely not common.
<FromGitter>
<cinnamonz:matrix.org> i see, good to know what's idiomatic. i'll stick with `T | Nil`.
<FromGitter>
<oprypin:matrix.org> cinnamonz (https://matrix.to/#/@cinnamonz:matrix.org): no i think it won't be reconsidered, even though I'm still all for it
<FromGitter>
<cinnamonz:matrix.org> I saw your spec_assert during my initial search, I'll give that a whirl tests. And thanks for the other link, I'll read it and get some inspiration.