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
sagax has quit [Quit: Konversation terminated!]
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 264 seconds]
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
<FromGitter> <mattrberry> Is there a way to accomplish circular references in the initialize function similar to how you would in ruby? ⏎ ⏎ ```class B ⏎ getter bar : A { A.new self } ⏎ end``` ⏎ ⏎ I'm guessing the best approach would just be to define a post_init function to call immediately after initialize? [https://gitter.im/crystal-lang/crystal?at=5f8e681ec7ef520fffb0f54d]
<FromGitter> <mattrberry> Also, unrelated: where's the best place to submit a feature request? I just learned that both clang and gcc warn "-Wshift-count-overflow" when doing the following ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ In Crystal, there is no compiler warning, so the result is just "0" since all the bits are shifted out. I've accidentally done this a number of times when working on my emulators haha
<FromGitter> <grkek> On the issue page
<FromGitter> <grkek> :)
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
zorp has joined #crystal-lang
yukai has quit [Ping timeout: 272 seconds]
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 272 seconds]
psydroid has quit [Quit: killed]
ryanprior has quit [Quit: killed]
return0e[m] has quit [Quit: killed]
return0e[m] has joined #crystal-lang
sagax has joined #crystal-lang
psydroid has joined #crystal-lang
ryanprior has joined #crystal-lang
<FromGitter> <bararchy> Is there an easy way of going over a string looking for a pattern and get in yield or array of indexes for where those patterns are in the string? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f8ec4d2a7e77a0ff15b79f6]
<FromGitter> <grkek> https://crystal-lang.org/api/0.20.4/Regex/MatchData.html#begin%28n%3D0%29-instance-method
<FromGitter> <grkek> You can write a function
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f8ec7e46c8d484be297b5c1]
<FromGitter> <grkek> this might work
<FromGitter> <grkek> :)
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f8ec88b7be0d67d27858542]
<FromGitter> <grkek> Better one with nil checking, monkey patching string is not a good idea fyi
<FromGitter> <grkek> Did that solve your problem?
<FromGitter> <grkek> ```"13123".magical_index_function(/123/) do |index| ⏎ puts index ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5f8ec91298a7774f1b5557be]
<FromGitter> <grkek> this is the way you use it
<FromGitter> <bararchy> Got something working :) ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f8ec96a631a250ab27e8216]
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f8ec9a5bbffc02b582aa2f8]
<FromGitter> <grkek> this is literally the function you asked for
<FromGitter> <grkek> Oh you wanted it in a loop
<FromGitter> <grkek> How about this?
<FromGitter> <grkek> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f8eca3fa0a3072b43930e63]
<FromGitter> <grkek> I would call that function `comb` since it combs the array and extracts the starting points haha
<FromGitter> <bararchy> comb is a good name :)
<yxhuvud> So isn't that what StringScanner does?
<FromGitter> <bararchy> ahahaha
<FromGitter> <bararchy> yes
<FromGitter> <bararchy> :facepalm:
<yxhuvud> or well you'd have to do the loop yourself.
<FromGitter> <grkek> Added the Swagger UI support to the framework :)
<FromGitter> <bararchy> yxhuvud: also, it seems StringScanner uses Regex, and it won't allow String input for pattern.
Liothen has quit [Ping timeout: 260 seconds]
Liothen has joined #crystal-lang
<FromGitter> <asterite> @bararchy there's `String#scan` and you can get indices by passing a regex: `"adasdasdasd123fdsdfsdfsdf123".scan(/123/) { |match| p! match.begin, match.end } ⏎ `
<FromGitter> <bararchy> @asterite that would be great for me, but Regex and LibPCR usage is a nogo, as the data might be binary which means libPCRE goes boom
<FromGitter> <asterite> Oh, I see... then I would make sure to use `byte_index` instead of `index` because `index` returns the codepoint index, not the byte index
<FromGitter> <bararchy> ohhhh
<FromGitter> <bararchy> nice one, does `byte_index` as a search option as well?
<FromGitter> <asterite> I don't think so. I was just saying, I saw the "solutions" above but they use `index` and they should use `byte_index` to loop over the string
<FromGitter> <j8r> why can't we use kwarg with `Proc#call`?
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
<FromGitter> <Dan-Do> I got this error ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f8f1ccf98a7774f1b5648ac]
<FromGitter> <Blacksmoke16> idt thats valid syntax
<FromGitter> <Dan-Do> weird
<FromGitter> <Blacksmoke16> i mean not weird, your syntax is wrong so it errors :p
<FromGitter> <Blacksmoke16> maybe the error isnt super clear in this case tho
<FromGitter> <Dan-Do> I just copied the syntax from https://github.com/crystal-lang/crystal/pull/9218
<FromGitter> <Blacksmoke16> right, that was a PR to implement that syntax, but it was closed
<FromGitter> <Blacksmoke16> i.e. not actually a feature (yet)
<FromGitter> <Dan-Do> oops, I saw some commit :(
Liothen has quit [Read error: Connection reset by peer]
Liothen has joined #crystal-lang
<FromGitter> <grkek> Static file handler added to Grip :)
<FromGitter> <grkek> I took most of it from amber also I may have discovered a bug?
<FromGitter> <grkek> I will try to verify it now
<FromGitter> <grkek> Yeah it is a bug
<FromGitter> <grkek> If you enable directory listing and list a directory not in the root of the public folder it redirects you forever.
o5r has quit [Quit: o5r]
f1refly has quit [Ping timeout: 258 seconds]
f1refly has joined #crystal-lang
HumanG33k has quit [Ping timeout: 272 seconds]
duane has joined #crystal-lang
sagax has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> jhass: you have any ideas on how to handle the case when my `run` script depends on the user's code itself?
<FromGitter> <Blacksmoke16> like id be nice if it inherited the scope of the caller
<FromGitter> <Blacksmoke16> it'd*
yukai has joined #crystal-lang
<FromGitter> <Blacksmoke16> or maybe add some flag to the `run` compiler run so that i could not invoke the `run` script again when its required
<FromGitter> <Blacksmoke16> even that wouldnt work tho I think tho, since the build script itself needs user code + lib code which i cant just require the users code in it :/
renich has joined #crystal-lang
<renich> Help! This: https://play.crystal-lang.org/#/r/9uwf gives me:
<renich> 26 | text = request.body["text"]
<renich> Error: undefined method '[]' for IO::ARGF (compile-time type is (IO | Nil))
<renich> ^
<renich> In src/bot.cr:26:24
<renich> whoops... sorry for the multi-line paste... I thought it would paste it in a single message. :S
<renich> In any case, I dunno why the Nil...