ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
notzmv has quit [Ping timeout: 255 seconds]
Sankalp- has joined #crystal-lang
Sankalp has quit [Ping timeout: 245 seconds]
Sankalp- is now known as Sankalp
notzmv has joined #crystal-lang
_ht has joined #crystal-lang
ur5us has joined #crystal-lang
jmdaemon has quit [Ping timeout: 264 seconds]
ur5us has quit [Quit: Leaving]
ur5us has joined #crystal-lang
hightower3 has joined #crystal-lang
hightower4 has quit [Ping timeout: 245 seconds]
casionaut has joined #crystal-lang
casionaut has quit [Quit: Client closed]
<FromGitter> <> 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> <> hmm, like raising an exception if the nilable return is nil?
<FromGitter> <> cinnamonz ( 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> <> 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> <> i see, good to know what's idiomatic. i'll stick with `T | Nil`.
<FromGitter> <> I was also thinking about an Assert macro today and saw the issue #4263 ( You think this could be reconsidered oprypin ( ?
<FromGitter> <> cinnamonz ( no i think it won't be reconsidered, even though I'm still all for it
<FromGitter> <> cinnamonz ( this is just ⏎ ⏎ ```macro assert(cond) ⏎ ({{cond}}) || raise{{cond.stringify}}) ⏎ end``` []
<FromGitter> <> and see for more advanced stuff here
<FromGitter> <> or for even more advanced (but isolated to unittests):
<FromGitter> <> 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.
notzmv has quit [Ping timeout: 240 seconds]
hightower3 has quit [Ping timeout: 255 seconds]
hightower2 has joined #crystal-lang
notzmv has joined #crystal-lang
_ht has quit [Quit: _ht]
jmdaemon has joined #crystal-lang