ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.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
Nicolab has joined #crystal-lang
<FromGitter> <Blacksmoke16> `Error: no overload matches 'Pointer(Athena::Serializer::PropertyMetadataBase)#[]=' with types Int32, Athena::Serializer::PropertyMetadata(String, TestObject)`
<FromGitter> <Blacksmoke16> well then
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8fbw
<FromGitter> <Blacksmoke16> minimal example
<FromGitter> <Blacksmoke16> (ofc i dont expect it to work but a better error would be helpful) main thing to note is `Test` includes `Parent` not `TypeBase`, which the method is typed to
<FromGitter> <tenebrousedge> is there a method to do the opposite of `humanize`? `"4.3k".frobnitz #=> 4300` ?
chachasmooth_ has joined #crystal-lang
chachasmooth has quit [Ping timeout: 260 seconds]
chachasmooth_ has quit [Quit: Quit]
chachasmooth has joined #crystal-lang
DTZUZU has quit [Quit: WeeChat 2.6]
DTZUZU has joined #crystal-lang
Nicolab has quit [Quit: Leaving.]
Nicolab has joined #crystal-lang
Nicolab has quit [Quit: Leaving.]
<FromGitter> <Blacksmoke16> not that i know of
<FromGitter> <tenebrousedge> that's okay, I wrote a quick one
_whitelogger has joined #crystal-lang
JuanMiguel has joined #crystal-lang
ur5us has joined #crystal-lang
Yxhuvud has joined #crystal-lang
JuanMiguel has quit [Quit: This computer has gone to sleep]
ur5us has quit [Ping timeout: 268 seconds]
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Quit: This computer has gone to sleep]
ua has quit [Ping timeout: 268 seconds]
ua has joined #crystal-lang
JuanMiguel has joined #crystal-lang
Nicolab has joined #crystal-lang
JuanMiguel has quit [Quit: This computer has gone to sleep]
gangstacat has quit [Quit: Ĝis!]
alexherbo26 has joined #crystal-lang
f1refly has quit [Quit: bye fags]
alex`` has quit [Ping timeout: 268 seconds]
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo26 is now known as alexherbo2
alex`` has joined #crystal-lang
alexherbo2 has quit [Read error: Connection timed out]
alexherbo2 has joined #crystal-lang
Nicolab has quit [Quit: Leaving.]
Human_G33k has quit [Ping timeout: 272 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Quit: Leaving]
gangstacat has joined #crystal-lang
gangstacat has quit [Remote host closed the connection]
gangstacat has joined #crystal-lang
ht_ has joined #crystal-lang
oz has quit [Ping timeout: 252 seconds]
oz has joined #crystal-lang
JuanMiguel has joined #crystal-lang
f1refly has joined #crystal-lang
JuanMiguel has quit [Quit: This computer has gone to sleep]
sorcus has quit [Quit: WeeChat 2.7]
Nicolab has joined #crystal-lang
<FromGitter> <manveru> shouldn't `JSON::Any.dig?` return nil instead of raising if an element is not found?
ur5us has joined #crystal-lang
<FromGitter> <manveru> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e24a326ea55e3623e816eb6]
<FromGitter> <tenebrousedge> hmmm
<FromGitter> <manveru> but even if i try to `dig?("a", "b")`, the returned value doesn't seem to actually be nil...
<FromGitter> <manveru> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e24a38e5cd79646607b28e3]
<FromGitter> <manveru> i'm a bit confused :)
<FromGitter> <manveru> since it does return `nil` in the inspect output, but the class is still `JSON::Any`, meaning `if` won't treat it as falsy
<FromGitter> <manveru> my eventual goal is to use `JSON.parse(j).dig?("a", "b", "c").try(&.as_s)`, and i expect that to be of type `String | Nil`, but it actually raises at runtime...
<FromGitter> <Blacksmoke16> dig probably assumes each value is a hash?
<FromGitter> <tenebrousedge> yeah
<FromGitter> <tenebrousedge> this seems to be intended
<FromGitter> <tenebrousedge> `rescue nil` :/
<FromGitter> <manveru> yeah... :|
<FromGitter> <manveru> the docs for `dig?` are a bit misleading then
<FromGitter> <manveru> i really wish option types were a bit more common in stdlib :)
<FromGitter> <dscottboggs_gitlab> > `rescue nil` :/ ⏎ ⏎ what? ⏎ ⏎ You can't raise nil...? [https://gitter.im/crystal-lang/crystal?at=5e24a5ef5cd79646607b3af3]
<FromGitter> <manveru> no, like `foo.dig?("bar") rescue nil`
<FromGitter> <tenebrousedge> ^
<FromGitter> <dscottboggs_gitlab> never seen that before, what's that mean?
<FromGitter> <manveru> inline rescue catches all exceptions by default, the rhs is the return value
<FromGitter> <dscottboggs_gitlab> oh i see
<FromGitter> <dscottboggs_gitlab> why would a method named `dig?` raise? that's confusing
<FromGitter> <manveru> exactly my point :)
<FromGitter> <dscottboggs_gitlab> haha
<FromGitter> <manveru> oh well, still beats writing 5 classes just to get one value...
<FromGitter> <tenebrousedge> related: https://github.com/crystal-lang/crystal/issues/7570
<FromGitter> <manveru> also strange that there's no `JSON::Any.as_nil?`
<FromGitter> <manveru> there is `as_nil`, but of course that also leads to runtime exceptions
<FromGitter> <manveru> then again... `as_nil?` would always return nil...
<FromGitter> <manveru> so i guess it wouldn't make any sense :P
<FromGitter> <grkek> Why would you want nil ?
<FromGitter> <manveru> i just don't want an exception
<FromGitter> <grkek> weird
<FromGitter> <Blacksmoke16> wrap it in begin/end and return nil on exception?
<FromGitter> <manveru> well, that's what i'm doing, but i just don't want an exception at all :)
<FromGitter> <manveru> i can implement my own `dig?` i guess...
<FromGitter> <Blacksmoke16> at this point wouldnt it be easier to make a few structs
<FromGitter> <manveru> no... not really
<FromGitter> <manveru> the rescue is much easier, it's just slower
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8fdb
repo has left #crystal-lang ["WeeChat 2.7"]
<FromGitter> <manveru> yeah, my example was simplified, i have 6 levels of nesting here
repo has joined #crystal-lang
<FromGitter> <manveru> the wonderful world of graphql
<repo> i sense irony
<repo> *sarcasm
<repo> i've worked a lot with graphql and found it quite nice
<FromGitter> <manveru> so it'd be more like `pp Hash(String, Hash(String, Hash(String, Hash(String, String?)?)?)?)` and so on
<FromGitter> <Blacksmoke16> whats the end goal here tho?
JuanMiguel has joined #crystal-lang
<FromGitter> <manveru> replacing `j.dig?("a", "b", "c") rescue nil` with something that doesn't raise?
<FromGitter> <grkek> use json any for nesting
ua has quit [Ping timeout: 260 seconds]
Nicolab has quit [Quit: Leaving.]
ur5us has quit [Ping timeout: 258 seconds]
ua has joined #crystal-lang
JuanMiguel has quit [Quit: This computer has gone to sleep]
sorcus has joined #crystal-lang
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Client Quit]
ht_ has quit [Remote host closed the connection]
alexherbo20 has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo20 is now known as alexherbo2
alex`` has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> There's a better way to do this.
<FromGitter> <dscottboggs_gitlab> wait....how to splat a tuple except the first element? https://carc.in/#/r/8fdt
<FromGitter> <dscottboggs_gitlab> whoops forgot to rewind the io
<FromGitter> <tenebrousedge> `_, a, b = tuple`
<FromGitter> <dscottboggs_gitlab> the io rental place is gonna be mildly annoyed at me
<FromGitter> <dscottboggs_gitlab> but I don't know how many elements are in the tuple because it came from a splat... wait can I do `_, *a = tuple`?
<FromGitter> <tenebrousedge> I don't think so
<FromGitter> <tenebrousedge> sec
<FromGitter> <dscottboggs_gitlab> nope https://carc.in/#/r/8fe0
<FromGitter> <dscottboggs_gitlab> I tried some wonky macro shit and that didn't work either https://carc.in/#/r/8fdy
<FromGitter> <Blacksmoke16> what are you trying to do?
<FromGitter> <dscottboggs_gitlab> dig into a nested json structure without using JSON.parse or creating separate classes
<FromGitter> <dscottboggs_gitlab> or do you mean *re-splat a received splat, with its first element dropped*?
<FromGitter> <dscottboggs_gitlab> the latter is what I'm asking the former is what I'm trying to do. haha
<FromGitter> <tenebrousedge> I'm not sure this is a thing
<FromGitter> <tenebrousedge> maybe with macro powers
<FromGitter> <dscottboggs_gitlab> nope https://carc.in/#/r/8fe2
<FromGitter> <dscottboggs_gitlab> oh, no I made a mistake https://carc.in/#/r/8fe4
<FromGitter> <tenebrousedge> `3.map` ?
<FromGitter> <dscottboggs_gitlab> yeah I meant https://carc.in/#/r/8fe6
<FromGitter> <dscottboggs_gitlab> ahahaha 😂 https://carc.in/#/r/8fe8
<FromGitter> <dscottboggs_gitlab> ah I give up haha
<FromGitter> <tenebrousedge> can you do `arg, key, *rest` ?
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e24e96d3ea53f0f66524952]
<FromGitter> <tenebrousedge> @dscottboggs_gitlab