ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
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> <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> <cinnamonz:matrix.org> I was also thinking about an Assert macro today and saw the issue #4263 (https://github.com/crystal-lang/crystal/issues/4263). You think this could be reconsidered oprypin (https://matrix.to/#/@oprypin:matrix.org) ?
<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> <oprypin:matrix.org> cinnamonz (https://matrix.to/#/@cinnamonz:matrix.org): this is just ⏎ ⏎ ```macro assert(cond) ⏎ ({{cond}}) || raise AssertionError.new({{cond.stringify}}) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=62e2d62f568c2c30d32a3e3f]
<FromGitter> <oprypin:matrix.org> and see for more advanced stuff here https://github.com/oprypin/crystal-dbus/blob/dd744b951dc2bc12399ac518f3a042965f64392b/src/util.cr#L24
<FromGitter> <oprypin:matrix.org> or for even more advanced (but isolated to unittests): https://github.com/search?q=user%3Aoprypin+spec_assert&type=code
<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.
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