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
<FromGitter> ... homogenous Array of symbol/string/char/... and inside the function will be doing a `map(&.to_s)`, but seems like a lot of possible combinations that need to be specified. ⏎ ⏎ Is there an easier or more compact way to represent this? [https://gitter.im/crystal-lang/crystal?at=611860324b7707158f81e7be]
<FromGitter> <nanobowers> Crystal's type system continues to be full of surprises (to me anyway). I would've thought that trying to pass in a value of `Array(Symbol)` into a function parameter that takes `Array(Symbol|String)` would be acceptable, but it appears I have to have that function parameter take `Array(Symbol) | Array(String) | Array(Symbol|String)` ⏎ ⏎ Ultimately i'd like to accept either a heterogenous or
ur5us_ has quit [Ping timeout: 252 seconds]
<FromGitter> <Blacksmoke16> also, whats your use case for using `Symbol`?
<FromGitter> <nanobowers> @Blacksmoke16 Thanks. Possible use of symbols mostly for user convenience and accepting something as close to ruby cut/paste as possible mainly for unittests
<FromGitter> <Blacksmoke16> Mmk, because they offer no benefit over a string, and an enum might also be better
notzmv has quit [Read error: Connection reset by peer]
sorcus has quit [Quit: WeeChat 3.2]
sorcus has joined #crystal-lang
notzmv has joined #crystal-lang
ur5us_ has joined #crystal-lang
ur5us has joined #crystal-lang
ur5us_ has quit [Read error: Connection reset by peer]
ur5us has quit [Ping timeout: 248 seconds]
ur5us has joined #crystal-lang
ur5us_ has joined #crystal-lang
ur5us has quit [Ping timeout: 252 seconds]
ur5us__ has joined #crystal-lang
ur5us_ has quit [Ping timeout: 268 seconds]
SamantazFox has joined #crystal-lang
ur5us_ has joined #crystal-lang
ur5us__ has quit [Ping timeout: 245 seconds]
ur5us__ has joined #crystal-lang
<FromGitter> <HertzDevil> an `Array(T | U)` restriction can take both `Array(T)` and `Array(U)` arguments (although it really shouldn't), unless e.g. that parameter declares an instance variable
ur5us_ has quit [Ping timeout: 272 seconds]
ur5us__ has quit [Ping timeout: 272 seconds]
<FromGitter> <asterite> I would avoid mixing symbols and strings. In fact, I would avoid symbols entirely
<yxhuvud> frown. It would have been nice if shards would have cloned recursively. Oh well, I guess I'll have to reimplement that in the makefile.
<yxhuvud> before anyone asks, no the submodule is not crystal and not controlled by me.
<FromGitter> <nanobowers> thanks @asterite and @Blacksmoke16 for the guidance on symbols, sounds like the best bet is to avoid them almost entirely. ⏎ ⏎ A test related question: My program has a top level main() which prints things to either stdout or stderr and calls exit() with a value. I would like to be test main() and be able to trap the exit() with the error code and also grab stdout/stderr (presumably to an IO::Memory
<FromGitter> ... buffer). I am able to trap the exit via `Signal::*.trap`, but not sure how to get the process exit status. Also, since STDOUT/STDERR are constants, i can't temporarily modify them or figure out how to . `Process.new` covers most of this, but only seems suitable for executing shell programs, not crystal code. Is the only so ... [https://gitter.im/crystal-lang/crystal?at=6119432b949a3d73863a11db]
<FromGitter> <Blacksmoke16> i think you have a few options
<FromGitter> <Blacksmoke16> 1) Built your binary and just invoke it via `Process.run`
<FromGitter> <Blacksmoke16> 2) Abstract the logic within `#main` to not be so tightly coupled with STDOUT/STDERR. I.e. allow providing `IO` instance for those, defaulted to what you want. Then instead of `exit` just have it return a value.
<FromGitter> <Blacksmoke16> could also then have a dedicated CLI entrypoint that handles doing the `exit` if needed
sagax has quit [Ping timeout: 240 seconds]
notzmv has quit [Ping timeout: 252 seconds]
notzmv has joined #crystal-lang
ur5us has joined #crystal-lang
Vexatos_ is now known as Vexatos
hightower3 has quit [Ping timeout: 248 seconds]
notzmv has quit [Ping timeout: 268 seconds]
<FromGitter> <postmodern:matrix.org> @nanobowers: I still need to port command_kit.rb to Crystal. It's API allows initializing the command class with a custom stdin, stdout, stderr, which can be StringIO instances that captures I/O and exit status'es are returned as an integer.
<FromGitter> <postmodern:matrix.org> ☝️ Edit (https://gitter.im/crystal-lang/crystal?at=6119a13a933ee46b755c1082): @nanobowers: I still need to port command_kit.rb to Crystal. It's API allows initializing the command class with a custom stdin, stdout, stderr, which can be StringIO instances that captures I/O and exit status'es are returned as an integer. ⏎ https://github.com/postmodern/command_kit.rb/blob/main/spec/stdio_spec.rb
SamantazFox has quit [Ping timeout: 272 seconds]