jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | 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
deavmi has quit [Ping timeout: 240 seconds]
deavmi has joined #crystal-lang
oddp has quit [Ping timeout: 264 seconds]
<FromGitter> <mixflame> cool
<FromGitter> <mixflame> thanks. I found at_exit only runs when "exit" is called
<FromGitter> <Blacksmoke16> ah, makes sense
sagax has quit [Remote host closed the connection]
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 272 seconds]
sagax has joined #crystal-lang
Vexatoast has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
Vexatos has quit [Ping timeout: 246 seconds]
Vexatos has joined #crystal-lang
duane has quit [Ping timeout: 264 seconds]
frojnd has quit [Quit: WeeChat 2.3]
deavmi has quit [Ping timeout: 272 seconds]
alexherbo2 has joined #crystal-lang
deavmi has joined #crystal-lang
jetpack_joe has quit [Ping timeout: 246 seconds]
<FromGitter> <alexherbo2> I forgot how to pass method with argument
<FromGitter> <alexherbo2> on map for example
<FromGitter> <alexherbo2> without block
jetpack_joe has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
<FromGitter> <throwaway4rust> Jesus I got so disappointed yesterday. I was trying a project in crystal but had to install it in ubuntu on multipass on Windows
<FromGitter> <throwaway4rust> i really wish Crystal can get the Windows version out :/
deavmi has joined #crystal-lang
oddp has joined #crystal-lang
<FromGitter> <naqvis> @alexherbo2 ⏎ ⏎ ```def do_sth(idx) ⏎ pp idx ⏎ end ⏎ ⏎ [1,2,3,4,5].map(&->do_sth(Int32))``` [https://gitter.im/crystal-lang/crystal?at=5f06e1d5bd3edf666fbbc562]
deavmi has quit [Ping timeout: 256 seconds]
Stephanie has quit [Disconnected by services]
Stephie has joined #crystal-lang
deavmi has joined #crystal-lang
sagax has quit [Remote host closed the connection]
postmodern has quit [Quit: Leaving]
<FromGitter> <asterite> Also: ⏎ ⏎ ```[1, 2, 3, 4, 5].map { |x| do_sth(x) }``` ⏎ ⏎ (I find it's always simpler to just call the method) [https://gitter.im/crystal-lang/crystal?at=5f0715cb86ccb45b59954e84]
<FromGitter> <asterite> I wish we would introduce the feature so you could do: ⏎ ⏎ ```[1, 2, 3, 4, 5].map &(do_sth(&1))``` [https://gitter.im/crystal-lang/crystal?at=5f0715e73c217837fd89985a]
<FromGitter> <asterite> then you would never need to use `->`
rocx has quit [Quit: 👏 developers 👏 developers 👏 developers 👏 developers]
Vexatos has quit [Ping timeout: 258 seconds]
Vexatos has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
sagax has joined #crystal-lang
<FromGitter> <j8r> @asterite what was the reason the RFC which can omit the argument types was not pursued?
<FromGitter> <asterite> I don't think it's intuitive
<FromGitter> <asterite> and it's a very specific use case
<FromGitter> <asterite> the proposal for short block syntax is more general and way more useful
<FromGitter> <j8r> maybe... but it the feature is a light addition, it would be definitely a nice to have
deavmi has joined #crystal-lang
rocx has joined #crystal-lang
<FromGitter> <asterite> it really depends... we can add a thousand little features, or just one feature that solves all of those issues
duane has joined #crystal-lang
<raz> after glancing over that PR i have to agree with "too cryptic". for smallbrainers like myself even the regular block syntax & semantics can be quite confusing at times.
<raz> with a shorthand like that i'd prob be tempted to use it, only to hurt myself when i try to understand the code again later
<FromGitter> <j8r> it is quite similar of how other languages work, like Python
<FromGitter> <j8r> this syntax already exists in crystal, the deal was only to not have to add argument types
<FromGitter> <j8r> `&->File.exists?(String)` (already valid) to `&->File.exists?`
<FromGitter> <naqvis> imho, its because procs are not first class citizen yet, so have to go through this whole fuss of annotating the param types. In other languages methods/funcs are first class citizen
<FromGitter> <naqvis> tbh passing procs as params is already too cryptic
<FromGitter> <naqvis> so hope in future, passing methods are args will become easier as other languages offer
alexherbo2 has quit [Ping timeout: 264 seconds]
<FromGitter> <asterite> procs are first class citizen, they just need an explicit type
<FromGitter> <asterite> for example in Elixir you need to do `&foo/1` or `&foo/2` to mention the arity. That doesn't mean they are not first class citizen, but you need to disambiguate based on number of arguments. Here it's the same except you also need to specify the type
<FromGitter> <naqvis> Thanks Ary for clarification. For overloaded methods it does make sense to disambiguate, but shouldn't be the case for others. Since procs are function pointers, so at the time of definition, things are already defined, then compiler shouldn't be instructed again on the very same.
commavir_ has joined #crystal-lang
psydroid has quit [*.net *.split]
commavir has quit [*.net *.split]
commavir_ is now known as commavir
ryanprior has quit [Write error: Connection reset by peer]
return0e[m] has quit [Read error: Connection reset by peer]
hamoko[m] has quit [Remote host closed the connection]
hamoko[m] has joined #crystal-lang
<raz> hm not sure about the "again"-part (you might be right on that). but one small gotcha i've bumped into repeatedly is how procs swallow the returned value (always nil) unless a return type is explicitly specified.
alexherbo2 has joined #crystal-lang
<raz> super minor thing tho, i'll admit. i've probably just not had a use-case yet where i would have benefited from the shorthand syntax (and therefore don't understand the upside intuitively)
alexherbo2 has quit [Ping timeout: 256 seconds]
return0e[m] has joined #crystal-lang
ryanprior has joined #crystal-lang
psydroid has joined #crystal-lang
<FromGitter> <naqvis> raz, just a contrived example ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f0756d446c75b1e5e34c7da]
<raz> hm yea, that one would look nicer w/o the repetition
<FromGitter> <naqvis> yeah, and this was that "again" i was referring to previously. Sorry for not being clear in initial post
<FromGitter> <kingsleyh> @kalinon awesome thanks - regarding entitas - I'll take a look - I've gone an OO approach so far - but ECS approach could work out well
<FromGitter> <jwoertink> If you're parsing XML, and you have a single Node, how do you get the value of a specific attribute?
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f075cdd46c75b1e5e34d7b6]
<FromGitter> <jwoertink> calling `attr.value` or `attr["id"]` even both raise errors
<FromGitter> <jwoertink> `node.attributes["id"]` will return `id="test"`
<FromGitter> <jwoertink> do I just have to split that every time?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/XML/Node.html# (attribute:String):String-instance-method
<FromGitter> <Blacksmoke16> `node["id"]`
<FromGitter> <jwoertink> 😂 omg... I don't know why I didn't think of calling it right on node
<FromGitter> <jwoertink> it just felt more intuitive that if I was iterating over attributes, I'd have access to all of it right there, I guess
<FromGitter> <jwoertink> Thanks
<FromGitter> <asterite> `puts attr.content` works too
<FromGitter> <jwoertink> Ah. Ok, so the strange thing with that is, if you do `puts attr.inspect`, you get `#<XML::Attribute:0x10522ce00 name="id" value="test">`
<FromGitter> <jwoertink> I didn't look to see if maybe `inspect` is overridden, but maybe that should look like `#<XML::Attribute:0x10522ce00 name="id" content="test">` ?
<FromGitter> <asterite> Good call, I think we should fix that
<FromGitter> <asterite> I'll send a PR
<FromGitter> <jwoertink> Ok. I'll open an issue about that.
<FromGitter> <jwoertink> Thanks!
alexherbo2 has joined #crystal-lang
<FromGitter> <kalinon> Anyone know an easy way to get the md5/sha1 of a file?
<FromGitter> <j8r> @kalinon ⏎ ⏎ ```require "digest/sha1" ⏎ ⏎ p Digest::SHA1.digest File.read PROGRAM_NAME``` [https://gitter.im/crystal-lang/crystal?at=5f077eda7455046699eb66e9]
<FromGitter> <j8r> you may want `Digest::SHA1.hexdigest`
<FromGitter> <kalinon> ok thats what i figured. perfect, thank you!
<Stephie> jhass, might want to up the number of workers on aarch64...
<Stephie> 4 seems like underworking this machine, doesn't it have like 64 cores?
alexherbo2 has quit [Ping timeout: 256 seconds]
<FromGitter> <Uzay-G> is there a way to get a language server like coc working with crystal in vim? I can prob use coc-ruby but im not sure how to set it up so it enables for crystal files
<FromGitter> <Blacksmoke16> anyone have snap installed that can do me a favor?
<oprypin> Blacksmoke16, `vagrant init ubuntu/focal64 && vagrant up`
<FromGitter> <Blacksmoke16> trying to figure out how im able to use my snap anywhere, when its defined as `strict` and didnt have any plugs
redplateaus[m] has joined #crystal-lang
<redplateaus[m]> Hey all - is there a way to have a fallback of some kind for `use_json_discriminator` when an unknown key is encountered?
<FromGitter> <Blacksmoke16> not that i know of, whats the use case?
<redplateaus[m]> I'm parsing an incoming JSON object from a third party. It consists of an array of "events", each of which has a "type". `use_json_discriminator` seems perfect to parse these into individual types, but I'd like it to not break if a new event type is added
<FromGitter> <Blacksmoke16> wouldnt you want it to break?, so you know there is a new type
<redplateaus[m]> My ideal is that any unrecognized event types fall back to some type I define such as UnknownEventType, so I deal with it however, while the rest of the array still gets parsed out like normal
<FromGitter> <Blacksmoke16> could just define your own macro with that added functionality
<FromGitter> <Blacksmoke16> copy what the original is doing, but instead of raising, use your fallback
<redplateaus[m]> Right on, I'll look into that. Just wanted to make sure it wasn't already baked in somehow. Thanks!
<redplateaus[m]> Sounds straightforward
<FromGitter> <Blacksmoke16> mhm