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
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <tenebrousedge> hmm. An age old dilemma. Play video games, or code?
<oprypin> code
<FromGitter> <Blacksmoke16> depends what game :P
<oprypin> i havent played a game in months, coding is so amazing
<FromGitter> <naqvis> simple solution: code a game :P
<FromGitter> <tenebrousedge> Mass Effect, Skyrim, Fallout 4, No Man's Sky, XCOM 2, or Deus Ex (GMDX)
<FromGitter> <Blacksmoke16> boo, code it is
<FromGitter> <tenebrousedge> noooooo you can't make me debug stuff 😿
<FromGitter> <tenebrousedge> okay fine
<FromGitter> <ImAHopelessDev_gitlab> both
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 256 seconds]
chachasmooth has quit [Ping timeout: 260 seconds]
chachasmooth has joined #crystal-lang
chachasmooth has quit [Ping timeout: 256 seconds]
chachasmooth has joined #crystal-lang
chachasmooth has quit [Ping timeout: 240 seconds]
chachasmooth has joined #crystal-lang
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
sagax has joined #crystal-lang
<FromGitter> <HertzDevil> does it ever make sense to pass a block and forward another one
<FromGitter> <HertzDevil> oh ruby has a syntax error for this actually
<Andriamanitra> i noticed "in" is a keyword in crystal.. where is it used? i tried searching but it's pretttty hard to find anything for such a commonly used word
<FromGitter> <naqvis> Andriamanitra `in` is used in exhaustive `case`
<FromGitter> <naqvis> `case when` requires `else` clause, so they added new keyword `in` to avoid adding `else` clause
<Andriamanitra> hmm, can you give an example?
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fc9f07929463f19c671d0b3]
<Andriamanitra> thanks, i think i understand.. although it is a bit weird
<FromGitter> <naqvis> `in` is exhaustive and it will decline to compile, if you haven't covered all branches (same behavior followed by other languages)
<FromGitter> <naqvis> this was lately added to language
<Andriamanitra> yeah, the word "in" just doesn't communicate the intent very clearly
<Andriamanitra> you'd think they would've at least considered something like exhaustive_case instead
f1refly2 has joined #crystal-lang
f1refly2 is now known as f1reflyylmao
<FromGitter> <HertzDevil> there's also `for ... in ...` but it's only available within macros
<f1reflyylmao> Is there a shortcut to get the last element from an array? I'm searching for some fancy alias function that would wrap arr[arr.size - 1] for me
<Andriamanitra> .last
<FromGitter> <HertzDevil> `arr[-1]`
<kevinsjoberg> I honestly believe my input for day 4 is broken :P
<kevinsjoberg> I got the right answer for part 1, I correctly validate all test inputs provided for p2, but the answer I provide is not correct.
<Andriamanitra> i was fortunate enough to not have any bugs, it would be a painful day to debug
<f1reflyylmao> Man, I cant read. Sorry for asking.
<kevinsjoberg> I honestly can see what I do wrong.
<Andriamanitra> have you tried with someone else's input?
<kevinsjoberg> Nope, I haven't
<kevinsjoberg> Have you done yours? Care to share?
<Andriamanitra> answers should be 219 and 127
<kevinsjoberg> I got 219 and 128.
<kevinsjoberg> Haha, wtf.
<kevinsjoberg> off by 1, I guess.
<kevinsjoberg> Yeah, my input was same. Reduced the result with one and got the star.
<kevinsjoberg> Hmm, code still broken then.
<yxhuvud> I also got the same input. that is weird. Perhaps he don't care to differentiate it until later on?
<kevinsjoberg> I basically do required_keys - passport.keys and ensure its empty
<kevinsjoberg> and then I just do logical and with a validation helper
<Andriamanitra> same as in identical? o_O
<kevinsjoberg> This is what I do
<kevinsjoberg> Am I blind? I've started at this for some time now.
<yxhuvud> I can recommend looking at the passports it accepts. At least one is wrong :)
<kevinsjoberg> But that's the thing. The test cases pass for the test input. I'll just run the puzzle input through the validator.
<Andriamanitra> maybe your regexes are matching partially?
<kevinsjoberg> Holy shit you're right.
<kevinsjoberg> Added \A \z and its down to 114.
<kevinsjoberg> Such a dumb mistake.
<yxhuvud> kevin, I didn't suggest you look at the test input, I suggested to look at the actual passports.
<kevinsjoberg> yeah, I got it a bit late. You wanted me to run the actual passports through the validator, right?
<yxhuvud> you can't trust that the test cases given cover all cases for your particular solution
<kevinsjoberg> true, I tend not to, but I felt confident enough about the validator given those cases passed and the logic was fairly simple.
<kevinsjoberg> but yeah, should probably get into the habit of playing around with the puzzle input more often.
<FromGitter> <Daniel-Worrall> everyone gets the same input
<Andriamanitra> no, there are definitely different inputs although i don't know how many
<FromGitter> <Daniel-Worrall> oh, huh
<postmodern> does anyone know of a crystal json streaming parser that can handle massive json files/streams? kind of want to write a generic json pretty printer that indents the json properly without loading it all into memory.
<kevinsjoberg> This is what I ended up with. Not the best, but it works.
<jhass> postmodern: stdlib JSON::PullParser is streaming and I'd say pretty performant
<jhass> and so is JSON::Builder
<jhass> so it should pretty much just be hooking up the two
<postmodern> jhass, trying to grok the API. appears i call #read_next and it returns a Symbol for the token, then i have to call the appropriate method to parse that object
<postmodern> guess that's another project for my TODO list
<postmodern> nice, jotted down in my notes
<jhass> hah, forgot about that one :D
<jhass> should use ARGF for input though
<postmodern> well dang
<postmodern> also should check STDOUT.tty? before colorizing
<postmodern> would be cool to somehow detect gzip input, and automatically start uncompressing it.
<jhass> doesn't gzip have a magic header?
<postmodern> gzip does have a header, but you can also output raw headerless gzip data
<jhass> with header it seems to always start with 1f 8b as magic value
<jhass> should be good enough to peek for that
<jhass> plus a cli flag to force enable
<jhass> or maybe checking PROGRAM_NAME for zfoo
<postmodern> https://tools.ietf.org/html/rfc1952#page-5 \x1f\x8b followed by \x08 is probably going to be gzip
<postmodern> oh yeah love the z program name pattern
<jhass> I mean of course if you'd go full unix philosophy here the right solution would be zcat | pretty_json
<jhass> :P
<hightower2> Hm I just realized I can't write e.g. Log.trace {%Q{ something }}, because: Error: unexpected token: {%
<hightower2> Is this something that could/should be fixed, or can't be?
<hightower2> (I mean to write this without a space in between)
postmodern has quit [Quit: Leaving]
<jhass> I don't think it should be fixed, you can argue for to parse as either {% Q() { something } or { %Q{something}
<jhass> help the compiler, help yourself, help the readers of your code, use proper formatting :)
<straight-shoota> technically, Q() is invalid ;)
<straight-shoota> but the same applies to q() which is a valid call
<straight-shoota> Or Q{something} as an array-like literal would be another interpretation
<FromGitter> <Daniel-Worrall> Isnt it right to indent it from the brace anyway
<FromGitter> <Daniel-Worrall> At least from styling perspective
<straight-shoota> yes
<raz> i'm not a fan of that logging syntax anyway :/
<FromGitter> <kingsleyh> is there any way i can see more info about why my binary fails to build? Error target axen failed to compile: is all it says
<FromGitter> <kingsleyh> it builds ok on 1 out of 3 identical AWS ubuntu servers - although maybe it's also intermittent
<jhass> that's from a `crystal build` invocation?
<FromGitter> <kingsleyh> shards build axen --release --no-debug
<jhass> try using `crystal build` directly
<FromGitter> <kingsleyh> same params?
<jhass> plus the main source file given for that target in the shard.yml
<jhass> well not plus, instead of the target name
<FromGitter> <kingsleyh> waiting for it do something
<FromGitter> <kingsleyh> still waiting .....
<FromGitter> <kingsleyh> what does this mean?
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fca378929463f19c67283c5]
<jhass> sounds like you ran out of memory
<FromGitter> <kingsleyh> ah ok - the servers are the small t2.micros
<FromGitter> <kingsleyh> ok working now that I stopped some stuff on the box
<riffraff169> isnt t2 deprecated? i think t3 is the new one, unless not available in that region
<FromGitter> <lodenos> Hello Crystal Community <3 ⏎ I try to doing something with the `JSON::Serializable` I’ve a spetific case I would like to do it ⏎ I would like at the moment the Serialization convert my int in string like as converter ⏎ ⏎ ```class Toto ⏎ @[JSON::Field(converter: self.test)] ⏎ getter tag : UInt16``` [https://gitter.im/crystal-lang/crystal?at=5fca48ee29463f19c672b24a]
<oprypin> lodenos, i dont understand
<FromGitter> <Blacksmoke16> the converter needs to be something that implements a `from_json(pull : JSON::PullParser)` method
<FromGitter> <Blacksmoke16> either a type, or object
<FromGitter> <lodenos> @oprypin I’ve edited
<FromGitter> <lodenos> @Blacksmoke16 Hum It’s this part I’vn’t understand
<FromGitter> <Dan-Do> here is my example ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fca49cfcef4f34f1f8d12ae]
<FromGitter> <lodenos> @Dan-Do Let me test for my case
<hightower2> Hey @Blacksmoke16 I see you've done something re. amqp-client. Do you know how to perform a basic_publish with (delivery_mode=2) to make msgs persistent? Is that the _confirm variant of the function or?
<hightower2> hm seems I should pass props:
<FromGitter> <ImAHopelessDev_gitlab> hai
<FromGitter> <Blacksmoke16> hightower2 its part of the `props` argument
<FromGitter> <Blacksmoke16> https://cloudamqp.github.io/amqp-client.cr/AMQ/Protocol/Properties.html#delivery_mode=(delivery_mode)-instance-method
<hightower2> right, figured it, thanks
<hightower2> (looked at the specs, there was one example using delivery_mode)
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <lodenos> Thx everybody, I’ve understand
<FromGitter> <lodenos> How do my thing :D
<FromGitter> <Blacksmoke16> πŸ‘
DTZUZU has quit [Quit: WeeChat 2.9]
DTZUZU has joined #crystal-lang
<kevinsjoberg> asterite: I just Advent of Code. I just checked out your solution for day 4 and stumbled upon Rule.new and started scratching my head.
<kevinsjoberg> That led me into the docs and now I'm a bit wiser. Really nice way of defining a proc.
<kevinsjoberg> oh, and I also learned about the ability to call methods on the case subject. That was sweet!
<kevinsjoberg> For reference, this was my own solution https://github.com/KevinSjoberg/aoc-2020/blob/main/04/day04.cr.
<FromGitter> <anapsix> cheers! ⏎ Is there a way to use `use_yaml_discriminator` with "from_yaml", as shows in the following example? ⏎ https://crystal-lang.org/api/0.34.0/YAML/Serializable.html#example
<FromGitter> <anapsix> a la https://play.crystal-lang.org/#/r/a1z1
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <anapsix> hmm.. I guess this works ⏎ https://play.crystal-lang.org/#/r/a1zj
duane has quit [Ping timeout: 260 seconds]
duane has joined #crystal-lang
<FromGitter> <anapsix> but then.. if it's `shape` is one level deeper, how do you do it? ⏎ ⏎ ```shape: ⏎ type: circle ⏎ x: 1 ⏎ y: 2 ⏎ radius: 3``` ⏎ ⏎ https://play.crystal-lang.org/#/r/a206 [https://gitter.im/crystal-lang/crystal?at=5fca620d89c5424e795a2bc5]
<FromGitter> <Blacksmoke16> i would think that should work
<FromGitter> <Blacksmoke16> try it with json and see if that works?
<FromGitter> <Blacksmoke16> try it against master, think that would fix it
<kevinsjoberg> This is different from Ruby, right? I believe class variables are shared among subclasses in Ruby.
<FromGitter> <Blacksmoke16> > Class variables are inherited by subclasses with this meaning: their type is the same, but each class has a different runtime value
<kevinsjoberg> Yeah, so different from Ruby then.
<FromGitter> <anapsix> > try it with json and see if that works? ⏎ ⏎ simple examples works: ⏎ ⏎ 1) yaml: https://play.crystal-lang.org/#/r/a20n ... [https://gitter.im/crystal-lang/crystal?at=5fca67964c1e954e644aae3d]
<FromGitter> <Blacksmoke16> try against master, im pretty sure it was fixed in that issue i ilnked
<kevinsjoberg> So I guess Crystal's class variables are the same as Ruby's class instance variables?
<FromGitter> <anapsix> yep yep.. getting master now
<hightower2> @Blacksmoke16 would you know if amqp-client is fiber-safe or?
<FromGitter> <Blacksmoke16> you mean thread safe?
<FromGitter> <Blacksmoke16> like for MT?
<hightower2> yeah
<FromGitter> <Blacksmoke16> no idea
<FromGitter> <Blacksmoke16> my contribution was using GH actions to build the docs
<hightower2> k, thanks, will look into the source
<hightower2> What's some nice/simple programming construct to retry a begin..end block if it raises an exception?
<FromGitter> <tenebrousedge> do you know about `def ... rescue ... end` ?
<FromGitter> <Blacksmoke16> https://github.com/Sija/retriable.cr
<hightower2> tenebrousedge yes
<FromGitter> <tenebrousedge> that's interesting @Blacksmoke16
<FromGitter> <tenebrousedge> so if your `begin` `end` block is scoped to the method, just call it again
<hightower2> nice one thanks @Blacksmoke16 !
<hightower2> tenebrousedge right but wouldn't a function calling itself keep increasing the function call depth? Also I would have to repeat the arguments to the function (not a big deal, but ideally I'd find something that literally retries, instead of me calling it again))
<FromGitter> <anapsix> I do wish there would be a way to pick master/HEAD version on play.crystal-lang.org
<FromGitter> <tenebrousedge> hightower2 probably, yeah. If `retriable` fits better, def use that
<straight-shoota> @anapsix just make a PR at https://github.com/jhass/carc.in =)
<straight-shoota> I actually already suggested that a while ago... https://github.com/jhass/carc.in/issues/9
<straight-shoota> nobody implemented it yet
<FromGitter> <Blacksmoke16> its possible with snap
<FromGitter> <Blacksmoke16> can do like `snap install crystal --edge`
<straight-shoota> nightly docker images have also been available for years
<FromGitter> <anapsix> point taken @straigh-shoota ⏎ is that the right repo, though? doesn't look like it has crystal 0.30+
<FromGitter> <j8r> @kingsleyh riffraff169 is right, we use t3a at work
<FromGitter> <j8r> they are cheaper, and have 1 core more for little instances
<straight-shoota> pretty sure, yes
<straight-shoota> unless jhass has another hidden repo somewhere
<straight-shoota> the software itself even runs on 0.34.0 so it should support 0.30+
<erdnaxeli> hi, is there something to know on a file if it is the "main" file executed? like `if __name__ == "__main__"` in python?
<FromGitter> <Blacksmoke16> i doubt it
<FromGitter> <Blacksmoke16> what are you trying to do?
<FromGitter> <tenebrousedge> I think it might though
<erdnaxeli> for the AoC I have one file per day, with some function, and then some calls to those functions. I just want those calls to not be done if I am importing the file, which IΒ do in the spec file.
<FromGitter> <tenebrousedge> kk cool
<FromGitter> <tenebrousedge> good to know
<erdnaxeli> that is exactly what I was looking for πŸ˜…
<FromGitter> <kingsleyh> @j8r I see - I was using the free tier which only lets me have a t2.micro
<erdnaxeli> but IΒ understand the argument against it
<FromGitter> <j8r> ha, cloud "free" tiers...
<FromGitter> <j8r> nowadays that I earn a bit of moneys, I prefer to spend few bucks to not be bothered
<FromGitter> <Blacksmoke16> prob could use flags to do something similar, given this is for AoC prob not a big deal if its a bit hacky
<FromGitter> <j8r> BTW if you start the instance only if you need, it won't cost you much, even if the instance is big
<FromGitter> <kingsleyh> yeah I will probably upgrade to some t3 - I need 6 constantly running
<FromGitter> <j8r> like, only few cents
<FromGitter> <Blacksmoke16> ```{% if flag? :run %} ⏎ method_calls ⏎ {% end %}``` ⏎ ⏎ `crystal run day1.cr -Drun` [https://gitter.im/crystal-lang/crystal?at=5fca7e354c1e954e644aec33]
<FromGitter> <j8r> @kingsleyh what I don't liek with AWS is to be bothered we reservations to save $$$
<FromGitter> <j8r> otherwise it can quite cost a lot
<FromGitter> <kingsleyh> I've just launched Axentro blockchain (formely SuchiChain) and it needs a few servers
<FromGitter> <kingsleyh> AWS is so hard to use lol
<FromGitter> <j8r> so true yeah
<FromGitter> <j8r> The console is a mess, we use Terraform now
<FromGitter> <j8r> Also, with an Auto Scaling Group, you can auto scale your servers depending of the load
<FromGitter> <kingsleyh> yeah it's hard to find anything in the console
<FromGitter> <kingsleyh> I'm trying to keep the costs down as they add up over time
<FromGitter> <j8r> it will be hard with AWS
<FromGitter> <kingsleyh> yeah but are there any other viable alternatives
<FromGitter> <j8r> I don't recommend it if the goal is for easy maintenance and cost saving πŸ˜…
<FromGitter> <j8r> DigitalOcean, Hetzner (mind it is in Europe)
<FromGitter> <j8r> I thing Azure and GCP are simpler
<FromGitter> <kingsleyh> I've used Hetzner but I didn't see any Loadbalancers etc
<FromGitter> <j8r> yes it lacks this things, I just see https://www.hetzner.com/cloud/load-balancer
<FromGitter> <kingsleyh> I thihnk that was not there last time I looked or maybe I missed it lol
<FromGitter> <j8r> for instance in AWS there is ALB, ELB, NLB lol
<FromGitter> <j8r> also you can use Terraform with it :) https://registry.terraform.io/providers/hetznercloud/hcloud/latest/docs
<FromGitter> <j8r> I mean, AWS can be nice, like K8S, but you need to have a little team full time to correctly manage it :/
<FromGitter> <j8r> you're correct, LB is new
<FromGitter> <j8r> ha also there is OVH as an other option, but I don't have much experience with it
<FromGitter> <anapsix> > try against master, im pretty sure it was fixed in that issue i ilnked ⏎ ⏎ while playing with HEAD, came up with this: https://play.crystal-lang.org/#/r/a229 ⏎ .. now I don't understand how it also works in Crystal 0.35.1 [https://gitter.im/crystal-lang/crystal?at=5fca82817133e319cb4fc2c9]
<FromGitter> <Blacksmoke16> maybe works diff on an array?
<FromGitter> <anapsix> also works with this ⏎ ⏎ ```shape: ⏎ type: point ⏎ x: 1 ⏎ y: 2``` [https://gitter.im/crystal-lang/crystal?at=5fca82efcef4f34f1f8daf54]
<straight-shoota> woa, I managed to get my super snaky validation code for today's AoC challenge to be correct on the first run
<straight-shoota> makes me a bit proud...
<kevinsjoberg> Haha, nice straight-shoota.
<kevinsjoberg> This is my implementation.
<yxhuvud> @straight-shoota: I had to add the third &&-case for the hgt: https://github.com/yxhuvud/aoc20/blob/master/day4.cr
<straight-shoota> I didn't even consider string ranges
<straight-shoota> but makes sense. Probably even more performant
<yxhuvud> not having to make a special case to be able to handle "180" without unit would have been nice though ..
<straight-shoota> yeah, ranges don't work with a suffix.
<yxhuvud> avoiding the ?.try(&.to_i?).try(&.in?( dance was nice though :)
<straight-shoota> for the number fields without a unit it makes perfectly sense
<straight-shoota> and for the heigh you could combine it with rchop
<straight-shoota> (hgt = pp["hgt"].rchop?("cm")) && hgt.in?("150".."193")
<yxhuvud> yeah that is less hacky :)
<FromGitter> <anapsix> > also works with this ⏎ > ``` ⏎ > shape: ⏎ > type: point ⏎ > x: 1 ... [https://gitter.im/crystal-lang/crystal?at=5fca87604c1e954e644b08da]
<FromGitter> <anapsix> and if I go "abstract" route, it works on HEAD, but not on 0.35.1
<FromGitter> <Blacksmoke16> normally you'd type the array to the top most type, which usually would be abstract
<FromGitter> <Blacksmoke16> versus a union of them all
<FromGitter> <anapsix> using an abstract struct allows me to use it as a type, instead of a union of them all
<FromGitter> <Blacksmoke16> right
<FromGitter> <tenebrousedge> hmm, case statements
<FromGitter> <tenebrousedge> also hmm, lots of `to_i`
<hightower2> Is there a built-in function somewhere which changes string "A::BcDef" to "a.bc_def" ?
<FromGitter> <Blacksmoke16> `str.gsub("::", ".").underscore.downcase`
<FromGitter> <Blacksmoke16> pretty sure underscore converts `::` to `_`
<straight-shoota> >> "A::BcDef".underscore
<DeBot> straight-shoota: # => "a::bc_def" - https://carc.in/#/r/a230
<FromGitter> <Blacksmoke16> nvm then
<hightower2> Ah ok, have the manual approach. Ok thanks
<straight-shoota> >> "A::BcDef".underscore.gsub("::", ".")
<DeBot> straight-shoota: # => "a.bc_def" - https://carc.in/#/r/a231
<FromGitter> <Blacksmoke16> oh so it also does downcase
<straight-shoota> yeah
* FromGitter * Blacksmoke16 goes and updates his `.underscore.downcase` calls
<FromGitter> <tenebrousedge> o.o
<FromGitter> <erdnaxeli:cervoi.se> Hi from matrix! The new bridge is up.
erdnaxeli has left #crystal-lang ["User left"]
<oprypin> @erdnaxeli:cervoi.se is this a new feature coming from matrix buying gitter?
<FromGitter> <erdnaxeli:cervoi.se> yep exactly
<oprypin> awesome awesome
<FromGitter> <oprypin:matrix.org> πŸ€”
<oprypin> the bridging was very slow
<FromGitter> <tenebrousedge> huh, right on
<oprypin> erdnaxeli:cervoi.se, was there any other step to make this more seamless towards irc?
<Andriamanitra> tenebrousedge: i really like your day 4 solution, using procs for the rules is so much cleaner than the monster of a case-when statement i ended up doing!
<Andriamanitra> i also hadn't seen record with a &block before, interesting
<FromGitter> <tenebrousedge> Andriamanitra hey thanks ^__^ I was feeling a little worried about that decision because everyone else seemed to go with a `case` or something
<FromGitter> <Daniel-Worrall> I think the really nice thing about AoC is getting the opportunity to work on the same puzzles and then getting insight into methods and ideologies of how to code better from more experience developers, and be able to talk about it afterwards in real time
<FromGitter> <tenebrousedge> did you post your solution earlier?
<FromGitter> <Daniel-Worrall> Uh, I posted mine in the discord, sec
<FromGitter> <Daniel-Worrall> Mine wasn't as neat as I'd like
<FromGitter> <Daniel-Worrall> Relying on rescuing is quite dirty lol
<Andriamanitra> i'm not happy with mine either but at least i managed to make it print a nice table that colors invalid fields red https://github.com/Andriamanitra/adventofcode2020/blob/main/day04/colorized.cr
<FromGitter> <Daniel-Worrall> I also did regex when I didn't need to
<FromGitter> <Daniel-Worrall> so slight inefficiencies
<FromGitter> <tenebrousedge> I would just have done the `begin` block over the whole method there
<FromGitter> <tenebrousedge> use the `def ... rescue ... end` thing
<FromGitter> <Daniel-Worrall> hmm, maybe, I just wanted to keep it contained to just that code that I knew what I was rescuing so it was clear on the intent
<FromGitter> <tenebrousedge> well, I split those up
<FromGitter> <tenebrousedge> thought it made more sense to have that be an `&&` rather than one big long procedure
<FromGitter> <Daniel-Worrall> 1 bit I was trying to do and didn't implement by the time I got the solution was short cirtcuiting failure. I had an array of the outcomes of the rules and just applied `#all?` which meant it had to evaluate them all
<FromGitter> <Daniel-Worrall> Also, didn't know I could do `from <= number <= to`
<FromGitter> <tenebrousedge> yes!
<FromGitter> <tenebrousedge> it's quite handy for I think day 03 too
<FromGitter> <Daniel-Worrall> day 2
<FromGitter> <tenebrousedge> ah, kay
<FromGitter> <tenebrousedge> :plus1:
<Andriamanitra> quite a few solutions also used ranges for the same thing, don't know which is actually better
<FromGitter> <tenebrousedge> I didn't bother with `to_i`
<FromGitter> <Daniel-Worrall> Asterite had a Rules and iterated with `#all?` so it would only test the rules until it hit failure
<FromGitter> <tenebrousedge> me too
<FromGitter> <tenebrousedge> huh
<FromGitter> <tenebrousedge> I should check his solution
<FromGitter> <Daniel-Worrall> Yeah, I'd like to see whch is more performant
<straight-shoota> ranges are super expressive for such things
<straight-shoota> like value.in? 150..200
<FromGitter> <Daniel-Worrall> cause it'll end up testing each case?
<FromGitter> <Blacksmoke16> @straight-shoota while you're here i noticed some things you prob know about
<FromGitter> <Blacksmoke16> er at least before i make issues/prs
<straight-shoota> shoot =)
<FromGitter> <Daniel-Worrall> I was looking for some sort of `#between?` method since I didn't know about `f<=x<=t`
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/MIME.html#from_filename(filename:String,default):String-class-method this should prob also accept `Path`
<FromGitter> <Daniel-Worrall> `Number#between(from, to)` RFC?
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/blob/5751927b339dd2616caec65f1b0830336f22cd58/src/file/preader.cr#L7 offset/limit on this are limited to `Int32`, i imagine that should be `Int64` to match the like `#read` methods?
<Andriamanitra> Daniel-Worrall: ranges don't actually test each case, it's smarter than that: https://github.com/crystal-lang/crystal/blob/5999ae29b/src/range.cr#L277
<straight-shoota> Blacksmoke16, I guess there are even more APIs that haven't been updated to include Path
<FromGitter> <tenebrousedge> hmm, maybe I should go back and use string ranges
<straight-shoota> it was already hard to convince everyone to have Path at all, so I didn't want to start spamming it everywhere. But then it got forgotten...
<FromGitter> <Daniel-Worrall> where does the expense come in that straight-shoota means? From initalising the Range?
<straight-shoota> Daniel-Worral expressive, not expensive
<FromGitter> <Blacksmoke16> i think it deff makes sense when working with files
<FromGitter> <Daniel-Worrall> AH
<FromGitter> <Daniel-Worrall> That's a derp on me
<FromGitter> <Blacksmoke16> like storing a path to a file, so that things could work on either linux or windows
<FromGitter> <Blacksmoke16> lastly, also related to that preader thing, thoughts on having `bytesize` be optional?
<FromGitter> <Blacksmoke16> i.e. "optionally only read x bytes, otherwise read rest of file from given offset"
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fcacd5f29463f19c6740d1b]
<FromGitter> <Blacksmoke16> is what im doing now :shrug: