ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.30.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
devil_tux has quit [Ping timeout: 244 seconds]
devil_tux has joined #crystal-lang
<FromGitter> <meltheadorable> πŸ˜’
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <codenoid> discord is heavy
alex`` has quit [Ping timeout: 268 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <betacomputer> what lang in crystal made in?
<FromGitter> <tenebrousedge> crystal
<FromGitter> <tenebrousedge> it's self hosted
<FromGitter> <betacomputer> ^w^
<FromGitter> <betacomputer> thank you
devil_tux has quit [Ping timeout: 268 seconds]
ht_ has joined #crystal-lang
<FromGitter> <watzon> Don't use `abstract` guys, it's pointless /s
<FromGitter> <watzon> Lol hope everyone's had a productive day, or is about to
ht_ has quit [Remote host closed the connection]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
moei has joined #crystal-lang
<FromGitter> <blankoworld> Hi all ;) ⏎ I think I need some help about github webhooks because I don't understand what I forget. ⏎ I read this: https://developer.github.com/webhooks/securing/#validating-payloads-from-github ⏎ And I attempt to do the same, with this code: ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5d5262b5029a51607f857e44]
<FromGitter> <blankoworld> (I just talk about the "hash", it's not the same)
<FromGitter> <absolutejam_gitlab> `MIME.init false` sorte for now
<FromGitter> <absolutejam_gitlab> Actually
<FromGitter> <absolutejam_gitlab> Had a bad URL
<FromGitter> <absolutejam_gitlab> that it couldn't resolve
<FromGitter> <atik7> Why puts (2**32).to_s , gives 0 in Crystal, but in ruby its working
flaviodesousa has joined #crystal-lang
<FromGitter> <naqvis> @atik7 that’s because output is beyond what `Int32` can hold. You can invoke this operation by casting the val to `Int64` like ⏎ ⏎ ```pp (2_i64 ** 32).to_s # => 4294967296``` [https://gitter.im/crystal-lang/crystal?at=5d5271451dadc42a11609942]
<FromGitter> <absolutejam_gitlab> Anyone know how I can get the query params from a http server handler?
<FromGitter> <absolutejam_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d5273b01dadc42a1160a913]
<FromGitter> <absolutejam_gitlab> Adding this handler, I assumed I'd be able to get the query params sent to the server
<FromGitter> <absolutejam_gitlab> The example URL getting hit is `http://localhost:8080/#access_token=<some token>&token_type=bearer`
<FromGitter> <vlazar> why would something that starts with `#` be in query params?
<FromGitter> <absolutejam_gitlab> Not sure why it's hitting that tbh, maybe I need to make it redirect `/succes` or something
<FromGitter> <absolutejam_gitlab> oh, but it's still not a query param
<FromGitter> <absolutejam_gitlab> Uhm
<FromGitter> <absolutejam_gitlab> It's not in `.path` either though
<FromGitter> <vlazar> you need `http://localhost:8080/?access_token=<some token>&token_type=bearer`
<FromGitter> <absolutejam_gitlab> ah, got it
<FromGitter> <absolutejam_gitlab> I changed the request to my OAuth server from `token` to `code`. Looks like it had different reponse mechanisms
<FromGitter> <absolutejam_gitlab> I wish there were some more examples or docs for `HTTP::Server`
<FromGitter> <absolutejam_gitlab> I just want to show a basic success message and the docs' example: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ don't seem to print output like I expected, and I don't know how to perform a redirect either [https://gitter.im/crystal-lang/crystal?at=5d527b3bbfd2887f53ddaef5]
<FromGitter> <absolutejam_gitlab> I basically want the redirect from my OAuth endpoint to hit a basic success page with the auth token removed from the URL
<FromGitter> <atik7> Thanks
Yxhuvud has quit [Ping timeout: 264 seconds]
<FromGitter> <naqvis> @absolutejam_gitlab you can invoke that by setting the status code and Location ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d528466bfd2887f53ddf07b]
alex`` has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Any idea about actually returning content?
<FromGitter> <absolutejam_gitlab> Thanks for the above response though, I'll try that in a mo
Yxhuvud has joined #crystal-lang
<FromGitter> <naqvis> you can return content via using `Response#print` or `Response#write`. But redirect shouldn’t contain any body as browsers/clients ignore the payload and just use the `Location`
<FromGitter> <absolutejam_gitlab> I've done `context.response.print` and there's nothing though, I just get `This page isn't working`
<FromGitter> <absolutejam_gitlab> I assumed just setting the content type and adding to the `IO` would print it
<FromGitter> <absolutejam_gitlab> This is prior to any redirects
<FromGitter> <absolutejam_gitlab> I'll probably redirect to a page that has a response message
<FromGitter> <Blacksmoke16> @absolutejam_gitlab that was a url fragment, prob part of the implicit SSO flow. uses the `#` because its a client side flow which shouldnt be accessible via a server
<FromGitter> <absolutejam_gitlab> Yeah, I'd done the implicit flow
<FromGitter> <absolutejam_gitlab> as I thought it was something else
<FromGitter> <Blacksmoke16> that would do it
sagax has joined #crystal-lang
lucasb has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> ohhh
<FromGitter> <absolutejam_gitlab> it's because I'm exiting too quickly and the server is running in a fiber
<FromGitter> <naqvis> did you invoked `Fiber.yield` ?
<FromGitter> <absolutejam_gitlab> No....
<FromGitter> <naqvis> you need to, as `spawn` isn’t guranteed to be executed immediately. So calling `Fiber.yield` will ensure that
<FromGitter> <absolutejam_gitlab> it's being launched though because I have a `puts` in there
<FromGitter> <naqvis> I would have draft a test case like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d52b90a5178a724767dd821]
<FromGitter> <naqvis> but main thread is getting done prior to spawned code get a chance to respond, so that in turn closed all other spawned processes from the main thread
<FromGitter> <absolutejam_gitlab> So, just `server.listen` in a fiber?
<FromGitter> <absolutejam_gitlab> I wrapped the whole HTTP Server in a function which I wrapped in a `spawn do`
<FromGitter> <Blacksmoke16> the server already spawns fibers to handle requests
<FromGitter> <absolutejam_gitlab> But I don't want the server running in the fg
<FromGitter> <Blacksmoke16> for writing specs?
<FromGitter> <absolutejam_gitlab> I'm basically spinning up the http server to receive the OAuth redirect and that's it
<FromGitter> <Blacksmoke16> ah
<FromGitter> <absolutejam_gitlab> and kinda show the 'success!' page
<FromGitter> <Blacksmoke16> sec
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/athena/blob/master/spec/routing/routing_spec_helper.cr#L13-L22 is what i do for athena when testing the server
<FromGitter> <Blacksmoke16> spawns the server in another fiber, runs the block, then stops the server
<FromGitter> <Blacksmoke16> could do something similar to start it, show the page, then stop it after?
<FromGitter> <kniknoo> I got my assembler working and spent this morning optimizing. String builder rocks! This morning it was taking me about 12 seconds to do a 26k line "pong" game and now I have it down to about 80 milliseconds.
<FromGitter> <kniknoo> I like the optimization features we have. I want to figure out a way to redefine the default Int to be, say, an Int16 or UInt8 instead of Int32. I presume if you can guarantee that you will never exceed your limit (or pay the rollover price) that there is a performance boost for working within a smaller word size.
<FromGitter> <kniknoo> It's been a while, but I remember a lot of these optimizations were handy for NeoPixel programming.
<FromGitter> <kniknoo> Also, are there no hints for mutable methods? I find that really useful and while I ended up skipping Array.delete_at() in the end, it would be nice to get ! hints still.
<FromGitter> <naqvis> great job and congratulations @kniknoo πŸ‘
<FromGitter> <kniknoo> Thank you! I can't wait to rewrite this for a more familiar grammar. For now, I'm on to chapter 7 where I'll get to make my first real stack VM using crystal!
<FromGitter> <naqvis> Crystal ain't a functional programming language and by default `Reference` types are immutable. Though one can achieve kind of immutability in Crystal by just using the `Value` types.
<FromGitter> <kniknoo> Yeah, I got my symbol table all accounted for, but there are still a few errant Int32s in my parser.
<FromGitter> <kniknoo> Still plenty for me to learn in this domain of crystal. The more I do this the more I want to write an ATMEGA assembler and my own bootloader for arduino.
duane has joined #crystal-lang
<FromGitter> <bararchy> @faustinoaq Seems the VScode extenstion is misbehaving with latest crystal (or our huge codebase?)
<FromGitter> <bararchy> It keep crashing
<FromGitter> <bararchy> Anyone else has this issue?
<FromGitter> <naqvis> @bararchy if you are using external programs like `scry`, then you will have to compile them after upgrading `crystal`. As Runtime has changed and those external programs are crashing in backend. You can validate the same by simply invoking those external programs and see if they run properly or not
<FromGitter> <bararchy> Makes sense
<FromGitter> <bararchy> I guess I'll disable SCRY for now
<FromGitter> <bararchy> until it works with 0.30.1
<FromGitter> <naqvis> it works
<FromGitter> <naqvis> i've recompiled that with 0.30.1
ht_ has joined #crystal-lang
<FromGitter> <bararchy> scry on `0.30.1` give me
<FromGitter> <bararchy> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d52d44a94bbaf4167a76bd2]
devil_tux has joined #crystal-lang
<FromGitter> <naqvis> apologies, i did that on `0.30.0_1` and was able to build scry shard
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d52d5ec5178a724767eb1bf]
<FromGitter> <kinxer> Is there a way to test if an object is an instance of a class that inherits a particular module? This doesn't work, but it's descriptive of what I'm trying to do:
<FromGitter> <kinxer> I am a fool. I just forgot a `.new`... Nevermind.
<FromGitter> <Blacksmoke16> can also use https://crystal-lang.org/api/master/Class.html#T.class):BoolforallT-class-method
<FromGitter> <kinxer> Ooh, right. Thank you.
<FromGitter> <naqvis> Though bit earlier to ask, but are `Hash` methods *thread-safe*? Or should one need to use `Mutex`?
<FromGitter> <naqvis> Though current implementation of `Mutex` isn't itself thread-safe yet
<Yxhuvud> It is not thread safe. Neither is Array methods.
<FromGitter> <naqvis> thanks Yxhuvud
devil_tux has quit [Ping timeout: 246 seconds]
<FromGitter> <absolutejam_gitlab> @Blacksmoke16 yeah I got something similar but the server is closing before It's been redirected as the main thread finishes
<FromGitter> <absolutejam_gitlab> Main fiber*
<FromGitter> <Blacksmoke16> try doing `sleep` instead of `Fiber.yield`
<FromGitter> <absolutejam_gitlab> sleep blocks everything though
<FromGitter> <Blacksmoke16> or like `sleep 1`
<FromGitter> <absolutejam_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d52f9fc2612bb718c5fd1cd]
<FromGitter> <absolutejam_gitlab> I've tried adding sleeps and loops with `Fiber.yield` but no dice so far
<FromGitter> <absolutejam_gitlab> I wonder if I do a blocking loop in the main fiber that waits for an exit from the channel
<FromGitter> <absolutejam_gitlab> Because if I `sleep` in the main fiber, it blocks the bg fiber too
<FromGitter> <Blacksmoke16> hmm, doing sleep in the main program should allow the other fibers to execute
<FromGitter> <absolutejam_gitlab> If I do say `sleep 4` in the main program, the redirect from GitLab to my localhost takes 4 seconds then everything continues and I get the 'server dead before redirecting' race condition
<FromGitter> <absolutejam_gitlab> Think I Might have it
<FromGitter> <tenebrousedge> o.o
fyber has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> what happens if you do like
<FromGitter> <Blacksmoke16> i remember something about using `sleep` with a loop
<FromGitter> <absolutejam_gitlab> https://play.crystal-lang.org/#/cr
<FromGitter> <absolutejam_gitlab> need a failure redirect but you get the idea
<FromGitter> <absolutejam_gitlab> seems weird that the `sleep 4` in the main program causes the background fiber to block too
rohitpaulk has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> mmm
<FromGitter> <absolutejam_gitlab> definitely says I should just be able to `sleep` in the main fiber
<FromGitter> <absolutejam_gitlab> maybe it's some weirdness with `server.listen` blocking
<FromGitter> <absolutejam_gitlab> dunno. Not really bothered as this is only a simple little thing
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <absolutejam_gitlab> Just seen the Ruby pipe operator debacle
<FromGitter> <tenebrousedge> :/
<FromGitter> <absolutejam_gitlab> Seems like a real lost opportunity
<FromGitter> <tenebrousedge> for?
<FromGitter> <absolutejam_gitlab> Wasting the pipe operator on a lower priority do
<FromGitter> <absolutejam_gitlab> Dot
<FromGitter> <absolutejam_gitlab> Elixir style functional pipe
<FromGitter> <absolutejam_gitlab> Pipe into first argument
<FromGitter> <tenebrousedge> I'd rather have seen Ruby adopt Crystal's `&.`
<FromGitter> <absolutejam_gitlab> I feel ruby and Crystal have some nice functional aspects that make the languages flexible
blassin has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <wontruefree> agreed
<FromGitter> <absolutejam_gitlab> how can I get a value out of my `loop`?
<FromGitter> <absolutejam_gitlab> oh i missed returning a value with break
<FromGitter> <absolutejam_gitlab> ty
<FromGitter> <Blacksmoke16> np
blassin has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> `resp_channel.send {:exit, nil}` ⏎ Gives me ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d5315c7bfd2887f53e20a35]
<FromGitter> <absolutejam_gitlab> Am I being dumb?
<FromGitter> <f1refly_gitlab> Hello there, I've got an issue with my compile and compiled crystal programs
<FromGitter> <Blacksmoke16> try using `()`
<FromGitter> <Blacksmoke16> on send
<FromGitter> <absolutejam_gitlab> I've wrapped in `()`
<FromGitter> <absolutejam_gitlab> oh wait
<FromGitter> <f1refly_gitlab> When I try to run a binay I get a `syncchanges: error while loading shared libraries: libevent-2.1.so.6: cannot open shared object file: No such file or directory` error
<FromGitter> <absolutejam_gitlab> I have 2 instance
<FromGitter> <absolutejam_gitlab> and only did one
<FromGitter> <f1refly_gitlab> And when I try to recompile I get tons of warning also related to that missing library
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7e8v gives same error w/o the paran
<FromGitter> <f1refly_gitlab> Although ldd lists it as correctly installed
<FromGitter> <f1refly_gitlab> https://pastebin.com/Gpz2ZDns
<FromGitter> <f1refly_gitlab> Should I contact my distros package maintainer about this or is it a crystal problem?
<FromGitter> <tenebrousedge> which distro?
<FromGitter> <f1refly_gitlab> Arch x64
<FromGitter> <absolutejam_gitlab> compiling with `--static`?
<FromGitter> <f1refly_gitlab> No, dynamic
<FromGitter> <f1refly_gitlab> Should I try static?
<oprypin> f1refly_gitlab, i think "compiling with `--static`" was a guess at something that definitely doesn't work
<FromGitter> <absolutejam_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d5316fd2612bb718c6094b7]
<oprypin> f1refly_gitlab, is it actually arch or manjaro?
<FromGitter> <absolutejam_gitlab> is my build script for a statically compiled/linked binary
<FromGitter> <absolutejam_gitlab> otherwise you'll need those libs on the target host
<FromGitter> <f1refly_gitlab> Everytime I try to compile now I have to cancel because it gets stuck and I have to restart to get rid of all the zombie processes that stay after killing it, so I'd rather not do that too much
<FromGitter> <absolutejam_gitlab> and I'm on manjaro
<FromGitter> <f1refly_gitlab> oprypin: vanilla arch
<oprypin> πŸ‘
<FromGitter> <absolutejam_gitlab> testing the artifact on same system?
<FromGitter> <f1refly_gitlab> the artifact?
<FromGitter> <absolutejam_gitlab> the binary
<FromGitter> <absolutejam_gitlab> that it spits out
<FromGitter> <f1refly_gitlab> yeah
<FromGitter> <absolutejam_gitlab> o
<FromGitter> <f1refly_gitlab> it doesnt spit out anything anymore though
<FromGitter> <absolutejam_gitlab> oh, it's failing when compiling
<FromGitter> <absolutejam_gitlab> I thought it compiled then complained when you tried to run it
<oprypin> absolutejam_gitlab, so umm i just ran `sudo pacman -Sy crystal` and was able to get your error
<oprypin> but the thing is, you must never run `pacman -Sy`
<FromGitter> <f1refly_gitlab> No, I tried running an old binary from before the `libevent` update
<oprypin> f1refly_gitlab, ah. well yeah, that'll do that as well, i suppose
<oprypin> u can compile it anew or give it the old libevent
<FromGitter> <f1refly_gitlab> oprypin: you should do that more often, the system tends to break after 6+ months of updates getting done at once in my experience
<oprypin> (which can also trigger a cascade of old whatever else)
<oprypin> f1refly_gitlab, im not sure what you mean
<oprypin> did u think i said that i never update my system? :p
<FromGitter> <f1refly_gitlab> > *<oprypin>* but the thing is, you must never run `pacman -Sy` ⏎ I misread that, so never mind
<FromGitter> <f1refly_gitlab> Yeah ^^'
<FromGitter> <f1refly_gitlab> > u can compile it anew or give it the old libevent
<FromGitter> <f1refly_gitlab> I can't compile it anew because the compiler is broken now :/
<oprypin> how is it broken
<FromGitter> <f1refly_gitlab> Should I run it to get some output?
<oprypin> uhhhh i suppose?
<oprypin> but only after you upgrade your system fully
<oprypin> just so we're not chasing a red herring
<FromGitter> <f1refly_gitlab> I'm fully updated, no worries
<FromGitter> <f1refly_gitlab> https://pastebin.com/DVYn8Sy1
<FromGitter> <f1refly_gitlab> This is the actual program I wan't to compile, but it's not the weird one
<oprypin> f1refly_gitlab, how about a `crystal eval 'p 7'`
<oprypin> (which works for me, in any case)
<FromGitter> <f1refly_gitlab> https://pastebin.com/7juM0VDx
<FromGitter> <f1refly_gitlab> Now I've got about a gazillion zombie crystal processes hanging around
<oprypin> that, like, really sucks?
<FromGitter> <Blacksmoke16> are you on `0.30.1`?
<FromGitter> <Blacksmoke16> event loop issue should be fixed
<oprypin> my `ldd $(which crystal)` looks identical
<FromGitter> <f1refly_gitlab> @Blacksmoke16 No, but I just did a system update
<FromGitter> <f1refly_gitlab> Give me a sec
<oprypin> i have 0.30.1
<FromGitter> <f1refly_gitlab> Seems to be a cache issue on my laptop, my desktop just installed the update
<FromGitter> <absolutejam_gitlab> I haven't bumped to `.1`, oops
<FromGitter> <f1refly_gitlab> I'll reboot quickly and clear caches
<oprypin> f1refly_gitlab, um it's not that kind of cache probably
<FromGitter> <f1refly_gitlab> Works fine on my Desktop now
<FromGitter> <f1refly_gitlab> So it probably will on my laptop too, sooner or later
<oprypin> pacman -Sy always checks latest, it's just that "latest" is according to whatever mirror you have configured first
<FromGitter> <Blacksmoke16> `rm -rf ~/.cache/crystal`
<oprypin> nono
<FromGitter> <f1refly_gitlab> `rm -rf /var/cache/pacman/pkg/*`
<FromGitter> <f1refly_gitlab> :)
<oprypin> also no
<FromGitter> <tenebrousedge> `sudo rm -rf /**/*cache*`
<FromGitter> <f1refly_gitlab> > https://pastebin.com/DVYn8Sy1 ⏎ ⏎ I still get this error on crystal 30.1, but it's probably related to the gpg shard I use not being updated
<oprypin> just delete the whole system
<FromGitter> <f1refly_gitlab> Can I restore from backup afterwards?
<oprypin> issa joke
<FromGitter> <f1refly_gitlab> I know, I'm just not good with humorous answers
<FromGitter> <f1refly_gitlab> But thank for the quick help anyways
<oprypin> f1refly_gitlab, anyway the real help can happen after this `grep '^S' /etc/pacman.d/mirrorlist | head -1`
<oprypin> i.e. what's the first configured mirror
<FromGitter> <Blacksmoke16> could also install via snap
<oprypin> cuz i have https://www.archlinux.org/mirrors/pseudoform.org/805/ and that's zero delay basically :D
<FromGitter> <f1refly_gitlab> oprypin: I used a mirror ranker to find the fastest one a year ago, but I'm willing to change. Would you recommend yours?
<FromGitter> <f1refly_gitlab> @Blacksmoke16 I won't because I despise the goals and design of snap
<FromGitter> <Blacksmoke16> 😐 fair enough
<oprypin> f1refly_gitlab, just check your mirror against https://www.archlinux.org/mirrors/ so we know that that's actually the problem
<FromGitter> <f1refly_gitlab> Don't take it personal, I'm sure you're a great guy :)
<FromGitter> <Blacksmoke16> to me it seems super helpful
<oprypin> my mirrorlist, for reference https://bpaste.net/show/Uoql
<FromGitter> <f1refly_gitlab> oprypin: I just copied the mirrorlist from my pc to my laptop and it works now, so yeah that was the issue
<FromGitter> <Blacksmoke16> vs having to worry about if your thing is on x but no y etc
<oprypin> on arch we dont worry
<FromGitter> <f1refly_gitlab> Yeah but it undermines the whole idea of dynamically linked packages, so you barely have any control over how old the libraries are that your computer is running
<FromGitter> <f1refly_gitlab> I personally don't want to use openssl from 2008
<FromGitter> <naqvis> How to retrieve an instance from an array, by providing a method the `Class` of the instance? Suppose I have an array consisting bunch of subclass instances, and I need to find one for particular sub-type. I've tried with `is_a?` but compiler giving me an error that it is expecting `CONST` instead of param name i've provided?
<FromGitter> <naqvis> contrived example ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d531ff7029a51607f8b168c]
<FromGitter> <tenebrousedge> pretty sure `is_a?` is a macro
<FromGitter> <naqvis> yeah true, it is
<FromGitter> <tenebrousedge> you maybe want a `case`
<oprypin> `def get(i : T.class) forall T` `.is_a? T`
<oprypin> (untested)
<FromGitter> <naqvis> thanks oprypin, let me give it a try
<oprypin> but that doesn't do the limitation to subclasses of Foo
<oprypin> instead u can try `a.class == i`
<oprypin> the difference is that `.class` matches only against the exact type, but `is_a?` also gets subclasses
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7e99
<FromGitter> <Blacksmoke16> that also works
<oprypin> wew
<FromGitter> <Blacksmoke16> no need for is_a etc
<FromGitter> <tenebrousedge> `select` works for that? neat
<FromGitter> <Blacksmoke16> yes if you pass it a type it filters on that type
<oprypin> that's so weird though
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7e9a
<FromGitter> <naqvis> thanks @Blacksmoke16 , you nailed it πŸ‘ πŸ˜†
<FromGitter> <Blacksmoke16> also can do that
ht_ has quit [Remote host closed the connection]
<oprypin> so changing `a.is_a? i` to `i === a` can do it
<oprypin> but does anyone else feel something is off about this
<FromGitter> <naqvis> oprypin can't do equality against an instance and a Class
<FromGitter> <Blacksmoke16> `@arr.find &.class.<=(type)`
<FromGitter> <Blacksmoke16> or in your case `==` maybe
<oprypin> um sorry https://carc.in/#/r/7e9g
<oprypin> `t = Int; t === 5`
<FromGitter> <tenebrousedge> ironically, the typescript gitter is having this same discussion, but the problem is not solvable, because TS types don't exist at runtime
<oprypin> what, at this exact time?
<FromGitter> <tenebrousedge> yes
<oprypin> thats ncie
<FromGitter> <naqvis> interesting enough πŸ˜†
<oprypin> what i'm saying is https://carc.in/#/r/7e9n
<oprypin> it's just that `===` already happens to be this kind of `foo`, just in standard library: https://github.com/crystal-lang/crystal/blob/b0cc6f70f2531e073f76b8e83f8be722e7ec2073/src/class.cr#L14
<FromGitter> <tenebrousedge> huh
<oprypin> and `select` directly uses `===` in case u weren't aware, and that's why that works
* FromGitter * tenebrousedge is now aware
<oprypin> ah it even says there https://crystal-lang.org/api/0.30.1/Enumerable.html#select(pattern)-instance-method
<oprypin> i actually didnt know myself, i usually think of `select` as accepting a block
<oprypin> ah dang, but then there's a redundant overload of `select` specifically for types πŸ˜‚ so woops, i wasn't technically right
<FromGitter> <Blacksmoke16> means you could also override `===` in your classes to change how select works
<FromGitter> <Blacksmoke16> and case as well
<oprypin> exactly
<oprypin> not that one really needs such a roundabout way to augment `select` if there's a direct way
duane has quit [Ping timeout: 258 seconds]
chachasmooth has quit [Ping timeout: 245 seconds]
chachasmooth has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
moei has quit [Quit: Leaving...]
alex`` has quit [Ping timeout: 248 seconds]