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
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
oddp has quit [Ping timeout: 240 seconds]
<FromGitter> <iambudi> Hi. can someone explain why atomic add() in a hash does not work? see line 4 in the playground https://play.crystal-lang.org/#/r/9ir7
postmodern has joined #crystal-lang
<FromGitter> <iambudi> @oprypin thanks, i did not know there's already discussion about that and still on going
zorp has joined #crystal-lang
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 265 seconds]
chachasmooth has quit [Ping timeout: 246 seconds]
chachasmooth has joined #crystal-lang
<postmodern> what does crystal do if LibC.malloc fails (out-of-memory)? will Pointer.malloc return nil, or raise an exception, or Sig 11?
alexherbo2 has joined #crystal-lang
<woodruffw> postmodern: i believe `Pointer.malloc` is implemented in terms of `GC.malloc`, which in turn is implemented in terms of either `LibGC.malloc` (boehm) or `LibC.malloc` directly. both of those return `Void*` and i can't find any checks against that value, so my best guess is that it'll segfault on OOM
<woodruffw> in particular `Pointer.malloc(size : Int, value : T)` and `Pointer.malloc(size : Int, &block : Int32 -> T)` should segfault right away on a null deref
<FromGitter> <ImAHopelessDev_gitlab> i love null dereferencing
<FromGitter> <grkek> How does one check if a string is in an array of strings?
<FromGitter> <naqvis> you will have to implement some custom mechanism to find that out, either find the `[` in the string and make a guess or you can use `JSON.parse` and see if it returns an array ⏎ ⏎ ```str = <<-STR ⏎ ["Hello", "World","Foo"] ⏎ STR ⏎ ⏎ pp JSON.parse(str).as_a?.nil? #=> false``` [https://gitter.im/crystal-lang/crystal?at=5f30e20cdca038052a5c3fb2]
alexherbo2 has quit [Ping timeout: 260 seconds]
<FromGitter> <iambudi> @grkek `["one","two","three"].includes?("three")`
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
<postmodern> is there a easier way to define methods that take UInt32 | Int32, convert to UInt32 but reject values < 0?
alexherbo2 has joined #crystal-lang
alexherbo23 has joined #crystal-lang
<postmodern> if a method is tagged with @[Raises(...)] and another method happens to call that method, does the calling method inherit the @[Raises]?
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo23 is now known as alexherbo2
<FromGitter> <naqvis> > *<postmodern>* if a method is tagged with @[Raises(...)] and another method happens to call that method, does the calling method inherit the @[Raises]? ⏎ ⏎ Answer is yes. The compiler infers this attribute for a method if it invokes a method that is marked as @[Raises] or raises (recursively).
<postmodern> naqvis, awesome!
oddp has joined #crystal-lang
<FromGitter> <naqvis> > *<postmodern>* is there a easier way to define methods that take UInt32 | Int32, convert to UInt32 but reject values < 0? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f3102c6d28b99685e5432e7]
<postmodern> naqvis, yeah that's what i thought. was wondering if there was a macro or something like #to_u32 that would raise on < 0 for me
<FromGitter> <naqvis> `-1.to_u32` should raise `Unhandled exception: Arithmetic overflow (OverflowError)`
zorp has quit [Ping timeout: 240 seconds]
postmodern has quit [Quit: Leaving]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 260 seconds]
HumanG33k has joined #crystal-lang
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
duane has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 264 seconds]
alexherbo2 has joined #crystal-lang
duane has quit [Ping timeout: 246 seconds]
duane has joined #crystal-lang
oddp has quit [Ping timeout: 256 seconds]
oddp has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
zorp has joined #crystal-lang
HumanG33k has joined #crystal-lang
<FromGitter> <wontruefree> I really enjoyed talking with Sergey Kuznetsov about Crystal the beginnings of the internet and Debuggers. Please enjoy my interview with Sergey. ⏎ http://podcast.chicagocrystal.org/1030945/4938446-sergey-kuznetsov-crystal-bbs-and-debuggershttps://youtu.be/dy6oiVbbH9c
<FromGitter> <j8r> Kuznetsov is a familiar name...
<FromGitter> <j8r> Ha, https://en.wikipedia.org/wiki/Nikolai_Kuznetsov_(admiral), which is also an aircraft carrier
<FromGitter> <j8r> Don't mind me 😅
mistergibson has joined #crystal-lang
postmodern has joined #crystal-lang
mistergibson has quit [Quit: Leaving]
zorp has quit [Ping timeout: 265 seconds]
<FromGitter> <dscottboggs_gitlab> I have a type which I wrote a method to deserialize with YAML::PullParser... ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Or do I need to rewrite the original `from_yaml` into a `.new(ctx, value)` somehow? [https://gitter.im/crystal-lang/crystal?at=5f31a8bf9231d665df6bc7cc]
<FromGitter> <Blacksmoke16> `OtherType.new parser`?
<FromGitter> <Blacksmoke16> or something along those lines?
<FromGitter> <dscottboggs_gitlab> yeah but `Bar` has a bazillion members and I wanted to use `YAML::Serializable` to parse it. YAML::Serializable doesn't define `.new(YAML::PullParser)` :(
<FromGitter> <Blacksmoke16> `OtherType.from_yaml parser.raw` or something like that maybe?
<FromGitter> <dscottboggs_gitlab> where would I get the parser from?
<FromGitter> <dscottboggs_gitlab> oh I guess I could try initializing one outside and passing it in
<FromGitter> <Blacksmoke16> normally you apply the converter to a given property
<FromGitter> <Blacksmoke16> which gives you access to that stuff
<FromGitter> <dscottboggs_gitlab> ...I don't see any docs for that
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f31ab319231d665df6bcf9c]
<FromGitter> <Blacksmoke16> ```@[YAML::Field(converter: Time::EpochConverter)] ⏎ @time : Time``` [https://gitter.im/crystal-lang/crystal?at=5f31ab42e20413052e7bbe50]
<FromGitter> <dscottboggs_gitlab> ah! that type signiature was what I needed, thank you
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> np
<FromGitter> <Sija> > How does one check if a string is in an array of strings? ⏎ ⏎ `“foo”.in?(“bar”, “baz”) # => false`
<FromGitter> <Blacksmoke16> `!!array.index("foo")` 😉
<oprypin> Blacksmoke16, uh why, jsut `array.includes?("foo")`
<FromGitter> <Blacksmoke16> i know, was just being a :trollface:
<FromGitter> <dscottboggs_gitlab> I'm confused...how do you advance to the next node when using `YAML::Nodes::Node`? Specifically I want to be able to translate ⏎ ⏎ ```{ name: "foo", values: { "bar" =>"baz", "dar" =>"daz"``` [https://gitter.im/crystal-lang/crystal?at=5f31bea69231d665df6c03e8]
<FromGitter> <dscottboggs_gitlab> so I can get `name = node.as(YAML::Nodes::Scalar).value` but then what do I do to get the mapping?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/YAML/PullParser.html#read_mapping(&)-instance-method
<FromGitter> <Blacksmoke16> that would get into `foo`
<FromGitter> <dscottboggs_gitlab> that's for `PullParser`, I'm looking at trying to use the `.new(ParseContext, Nodes::Node)` overload used by `Serializable`
<FromGitter> <Blacksmoke16> oh
<FromGitter> <dscottboggs_gitlab> yeah that was how I did it before
<FromGitter> <Blacksmoke16> prob be something in there
<FromGitter> <dscottboggs_gitlab> I don't really see any way to do this without also manually writing an overload of `#initialize(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : ::YAML::Nodes::Node)` in the parent type 😦
<FromGitter> <dscottboggs_gitlab> only a `YAML::Mapping` has access to its child nodes, you can't just say "give me the next node" like with a PullParser
oddp has quit [Ping timeout: 264 seconds]
<FromGitter> <dscottboggs_gitlab> TBH I think this is due to a technical limitation in YAML, but it would be nice if YAML::Serializable somehow supported YAML::Pullparser for documents that can be parsed with it (I.E. those without anchors)
alexherbo2 has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> :shrug: possibly
<FromGitter> <Blacksmoke16> `BUG: `max` at /home/george/dev/git/athena-framework/validator/src/constraints/range.cr:44:70 has no type (Exception)` 😐
<FromGitter> <dscottboggs_gitlab> > "has no type" ⏎ ⏎ excuse me, Mr. Compiler?
<FromGitter> <Blacksmoke16> its smoking
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f31d487811d3571b3bbefe9]
<FromGitter> <Blacksmoke16> complains that `Error: no overload matches 'Float64#>' with type Nil`
<FromGitter> <Blacksmoke16> even tho im checking it in the `if`?
<FromGitter> <Blacksmoke16> nvm, was missing some `()`
<FromGitter> <Blacksmoke16> ```Finished in 3.66 milliseconds ⏎ 181 examples, 0 failures, 0 errors, 1 pending``` [https://gitter.im/crystal-lang/crystal?at=5f31d664dca038052a5ef5cc]
<FromGitter> <Blacksmoke16> 👏