00:39
Nicolab has joined #crystal-lang
00:46
<
FromGitter >
<Blacksmoke16> `Error: no overload matches 'Pointer(Athena::Serializer::PropertyMetadataBase)#[]=' with types Int32, Athena::Serializer::PropertyMetadata(String, TestObject)`
00:46
<
FromGitter >
<Blacksmoke16> well then
01:01
<
FromGitter >
<Blacksmoke16> minimal example
01:02
<
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
01:21
<
FromGitter >
<tenebrousedge> is there a method to do the opposite of `humanize`? `"4.3k".frobnitz #=> 4300` ?
01:27
chachasmooth_ has joined #crystal-lang
01:28
chachasmooth has quit [Ping timeout: 260 seconds]
01:32
chachasmooth_ has quit [Quit: Quit]
01:32
chachasmooth has joined #crystal-lang
01:59
DTZUZU has quit [Quit: WeeChat 2.6]
02:03
DTZUZU has joined #crystal-lang
02:23
Nicolab has quit [Quit: Leaving.]
02:28
Nicolab has joined #crystal-lang
03:49
Nicolab has quit [Quit: Leaving.]
04:30
<
FromGitter >
<Blacksmoke16> not that i know of
04:31
<
FromGitter >
<tenebrousedge> that's okay, I wrote a quick one
07:19
_whitelogger has joined #crystal-lang
08:08
JuanMiguel has joined #crystal-lang
08:47
ur5us has joined #crystal-lang
09:02
Yxhuvud has joined #crystal-lang
09:14
JuanMiguel has quit [Quit: This computer has gone to sleep]
09:19
ur5us has quit [Ping timeout: 268 seconds]
09:48
JuanMiguel has joined #crystal-lang
10:06
JuanMiguel has quit [Quit: This computer has gone to sleep]
10:49
ua has quit [Ping timeout: 268 seconds]
11:03
ua has joined #crystal-lang
11:22
JuanMiguel has joined #crystal-lang
11:47
Nicolab has joined #crystal-lang
11:51
JuanMiguel has quit [Quit: This computer has gone to sleep]
13:07
gangstacat has quit [Quit: Ĝis!]
13:55
alexherbo26 has joined #crystal-lang
13:55
f1refly has quit [Quit: bye fags]
13:57
alex`` has quit [Ping timeout: 268 seconds]
13:57
alexherbo2 has quit [Ping timeout: 268 seconds]
13:57
alexherbo26 is now known as alexherbo2
13:58
alex`` has joined #crystal-lang
14:22
alexherbo2 has quit [Read error: Connection timed out]
14:23
alexherbo2 has joined #crystal-lang
14:45
Nicolab has quit [Quit: Leaving.]
14:57
Human_G33k has quit [Ping timeout: 272 seconds]
15:02
HumanG33k has joined #crystal-lang
15:19
HumanG33k has quit [Quit: Leaving]
16:11
gangstacat has joined #crystal-lang
16:11
gangstacat has quit [Remote host closed the connection]
16:11
gangstacat has joined #crystal-lang
16:34
ht_ has joined #crystal-lang
17:11
oz has quit [Ping timeout: 252 seconds]
17:14
oz has joined #crystal-lang
17:33
JuanMiguel has joined #crystal-lang
17:34
f1refly has joined #crystal-lang
17:48
JuanMiguel has quit [Quit: This computer has gone to sleep]
18:34
sorcus has quit [Quit: WeeChat 2.7]
18:40
Nicolab has joined #crystal-lang
18:41
<
FromGitter >
<manveru> shouldn't `JSON::Any.dig?` return nil instead of raising if an element is not found?
18:42
ur5us has joined #crystal-lang
18:43
<
FromGitter >
<tenebrousedge> hmmm
18:44
<
FromGitter >
<manveru> but even if i try to `dig?("a", "b")`, the returned value doesn't seem to actually be nil...
18:44
<
FromGitter >
<manveru> i'm a bit confused :)
18:46
<
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
18:47
<
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...
18:49
<
FromGitter >
<Blacksmoke16> dig probably assumes each value is a hash?
18:50
<
FromGitter >
<tenebrousedge> yeah
18:50
<
FromGitter >
<tenebrousedge> this seems to be intended
18:50
<
FromGitter >
<tenebrousedge> `rescue nil` :/
18:50
<
FromGitter >
<manveru> yeah... :|
18:52
<
FromGitter >
<manveru> the docs for `dig?` are a bit misleading then
18:54
<
FromGitter >
<manveru> i really wish option types were a bit more common in stdlib :)
18:55
<
FromGitter >
<manveru> no, like `foo.dig?("bar") rescue nil`
18:55
<
FromGitter >
<tenebrousedge> ^
18:55
<
FromGitter >
<dscottboggs_gitlab> never seen that before, what's that mean?
18:55
<
FromGitter >
<manveru> inline rescue catches all exceptions by default, the rhs is the return value
18:55
<
FromGitter >
<dscottboggs_gitlab> oh i see
18:56
<
FromGitter >
<dscottboggs_gitlab> why would a method named `dig?` raise? that's confusing
18:56
<
FromGitter >
<manveru> exactly my point :)
18:56
<
FromGitter >
<dscottboggs_gitlab> haha
18:57
<
FromGitter >
<manveru> oh well, still beats writing 5 classes just to get one value...
19:00
<
FromGitter >
<manveru> also strange that there's no `JSON::Any.as_nil?`
19:00
<
FromGitter >
<manveru> there is `as_nil`, but of course that also leads to runtime exceptions
19:01
<
FromGitter >
<manveru> then again... `as_nil?` would always return nil...
19:01
<
FromGitter >
<manveru> so i guess it wouldn't make any sense :P
19:04
<
FromGitter >
<grkek> Why would you want nil ?
19:12
<
FromGitter >
<manveru> i just don't want an exception
19:13
<
FromGitter >
<grkek> weird
19:13
<
FromGitter >
<Blacksmoke16> wrap it in begin/end and return nil on exception?
19:13
<
FromGitter >
<manveru> well, that's what i'm doing, but i just don't want an exception at all :)
19:14
<
FromGitter >
<manveru> i can implement my own `dig?` i guess...
19:14
<
FromGitter >
<Blacksmoke16> at this point wouldnt it be easier to make a few structs
19:15
<
FromGitter >
<manveru> no... not really
19:16
<
FromGitter >
<manveru> the rescue is much easier, it's just slower
19:17
repo has left #crystal-lang ["WeeChat 2.7"]
19:18
<
FromGitter >
<manveru> yeah, my example was simplified, i have 6 levels of nesting here
19:18
repo has joined #crystal-lang
19:18
<
FromGitter >
<manveru> the wonderful world of graphql
19:18
<
repo >
i sense irony
19:19
<
repo >
i've worked a lot with graphql and found it quite nice
19:19
<
FromGitter >
<manveru> so it'd be more like `pp Hash(String, Hash(String, Hash(String, Hash(String, String?)?)?)?)` and so on
19:19
<
FromGitter >
<Blacksmoke16> whats the end goal here tho?
19:19
JuanMiguel has joined #crystal-lang
19:20
<
FromGitter >
<manveru> replacing `j.dig?("a", "b", "c") rescue nil` with something that doesn't raise?
19:21
<
FromGitter >
<grkek> use json any for nesting
19:21
ua has quit [Ping timeout: 260 seconds]
19:23
Nicolab has quit [Quit: Leaving.]
19:34
ur5us has quit [Ping timeout: 258 seconds]
19:35
ua has joined #crystal-lang
19:36
JuanMiguel has quit [Quit: This computer has gone to sleep]
20:49
sorcus has joined #crystal-lang
22:02
JuanMiguel has joined #crystal-lang
22:03
JuanMiguel has quit [Client Quit]
22:03
ht_ has quit [Remote host closed the connection]
22:52
alexherbo20 has joined #crystal-lang
22:54
alex`` has quit [Ping timeout: 268 seconds]
22:54
alexherbo2 has quit [Ping timeout: 260 seconds]
22:54
alexherbo20 is now known as alexherbo2
22:56
alex`` has joined #crystal-lang
22:56
<
FromGitter >
<dscottboggs_gitlab> There's a better way to do this.
23:18
<
FromGitter >
<dscottboggs_gitlab> whoops forgot to rewind the io
23:19
<
FromGitter >
<tenebrousedge> `_, a, b = tuple`
23:19
<
FromGitter >
<dscottboggs_gitlab> the io rental place is gonna be mildly annoyed at me
23:19
<
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`?
23:20
<
FromGitter >
<tenebrousedge> I don't think so
23:20
<
FromGitter >
<tenebrousedge> sec
23:23
<
FromGitter >
<Blacksmoke16> what are you trying to do?
23:23
<
FromGitter >
<dscottboggs_gitlab> dig into a nested json structure without using JSON.parse or creating separate classes
23:24
<
FromGitter >
<dscottboggs_gitlab> or do you mean *re-splat a received splat, with its first element dropped*?
23:25
<
FromGitter >
<dscottboggs_gitlab> the latter is what I'm asking the former is what I'm trying to do. haha
23:27
<
FromGitter >
<tenebrousedge> I'm not sure this is a thing
23:28
<
FromGitter >
<tenebrousedge> maybe with macro powers
23:32
<
FromGitter >
<tenebrousedge> `3.map` ?
23:34
<
FromGitter >
<dscottboggs_gitlab> ah I give up haha
23:38
<
FromGitter >
<tenebrousedge> can you do `arg, key, *rest` ?
23:51
<
FromGitter >
<tenebrousedge> @dscottboggs_gitlab