jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.0 | 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
<FromGitter> <Blacksmoke16> hm, would it make sense for `Bool` to include `Comparable`, i noticed i cant sort an array of bools
<FromGitter> <Blacksmoke16> er rather sort_by a bool
<FromGitter> <Blacksmoke16> `.sort_by { |c| c.primary ? -1 : 1 }` just did this for now
<FromGitter> <Blacksmoke16> (i want it to be first hence `-1` instead of `1` for true)
alexherbo26 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
rohitpaulk has joined #crystal-lang
alexherbo26 has quit [Ping timeout: 246 seconds]
bmcginty has quit [Ping timeout: 245 seconds]
rohitpaulk has quit [Ping timeout: 245 seconds]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 250 seconds]
bmcginty has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
return0e_ has quit [Ping timeout: 258 seconds]
return0e has joined #crystal-lang
misaki_m has joined #crystal-lang
misaki_m has quit [Quit: Mutter: www.mutterirc.com]
waheedi has joined #crystal-lang
<FromGitter> <straight-shoota> @Blacksmoke16 `Bool` has no inherent order, so it can't be `Comparable`
<FromGitter> <straight-shoota> see #5162
<DeBot> https://github.com/crystal-lang/crystal/issues/5162 (implement '<=>' for Bool)
ashirase has quit [Ping timeout: 246 seconds]
ashirase has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
hightower2 has joined #crystal-lang
alexherbo26 has joined #crystal-lang
alexherbo266 has joined #crystal-lang
alexherbo26 has quit [Ping timeout: 245 seconds]
flaviodesousa has joined #crystal-lang
flaviodesousa has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> 👍
flaviodesousa has joined #crystal-lang
<FromGitter> <Blacksmoke16> makes sense yea
flaviodesousa has quit [Max SendQ exceeded]
flaviodesousa has joined #crystal-lang
waheedi has quit [Quit: waheedi]
lucasb has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<oprypin> python doesnt bother, just says True==1 and ayy it''s orderable
<FromGitter> <Blacksmoke16> for what you can sort by i guess its easier to do like `bool ? 1 : -1` or vice versa if you want opposite order
<FromGitter> <Blacksmoke16> vs would have to do like `.sort_by { |c| c.primary }.reverse`, :shrug:
<FromGitter> <Blacksmoke16> meh
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
waheedi has joined #crystal-lang
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
alexherbo2668 has joined #crystal-lang
alexherbo266 has quit [Ping timeout: 246 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <yxhuvud> oprypin: rather, python thinks 0 is false, and everything else is true.
<FromGitter> <j8r> @yxhuvud except `None`
<FromGitter> <yxhuvud> Ah, right.
alexherbo2668 is now known as alex2``
rohitpaulk has quit [Ping timeout: 246 seconds]
hightower2 has quit [Ping timeout: 246 seconds]
<FromGitter> <fenicks> Hi everyone
<FromGitter> <j8r> Hello the one that has a Crystal logo as avatar 😄
<FromGitter> <fenicks> I'm using crystal-db with postgresql driver. I looking a way to use bulk/batch insert, any idea ? ConnectionPool looks not enough.
<FromGitter> <fenicks> @j8r I felt in love. This logo is awesome !
tdc has quit [Quit: Leaving]
<FromGitter> <straight-shoota> @fenicks You can build a statement using `Connection#build` and then call `Statement#exec`/`Statement#query` with each argument set
<FromGitter> <straight-shoota> I don't think the postgres driver supports prepared statements yet, though.
<FromGitter> <jwoertink> https://vlang.io/ "Fast compile, Hot Code Reloading, and a REPL". ... We've got some catching up to do! 😂
<FromGitter> <fridgerator> I just saw vlang yesterday, looks awesome
rohitpaulk has joined #crystal-lang
<FromGitter> <fridgerator> "V compiles ≈1.5 million lines of code per second per CPU core" and it can translace c / c++ into v !
<FromGitter> <fridgerator> translate*
<FromGitter> <fridgerator> the syntax though, looks inspired by Go quite a bit
<FromGitter> <jwoertink> Yeah. Looks like it's a closed source language for now. Interesting concept though
<FromGitter> <pynixwang> more like rust
<FromGitter> <j8r> It's easy to say that for vlang, they haven't provided anything as for now
<FromGitter> <aemadrid> this looks impressive: https://volt-app.com/img/lang.webm
laaron- has joined #crystal-lang
<FromGitter> <j8r> nim supports hot reload too
<FromGitter> <j8r> It uses dynamically linked libraries for this
laaron has quit [Ping timeout: 256 seconds]
<FromGitter> <pynixwang> we need a real repl
<FromGitter> <fenicks> > @fenicks You can build a statement using `Connection#build` and then call `Statement#exec`/`Statement#query` with each argument set ⏎ ⏎ Will try. Thanks
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <bew> @j8r you could do it in Crystal too, i saw a simple poc with hot reloading once, in Crystal
<FromGitter> <bew> You need to organize your program in a certain way, be able to isolate the state, the inputs, etc.. And routines to unload, reload another vers
<FromGitter> <bew> Version of the lib, etc..
<FromGitter> <girng> looks like rust and golang had a baby
<FromGitter> <jwoertink> When using `expect_raises`, it's a regex for the second arg to say the error should contain "this", right?
<FromGitter> <jwoertink> I just want to make sure that the error contains something, but not that it's necessarily equal to something
<FromGitter> <jwoertink> oh, ok. Looks like I needed `Regex.new(my_string)`. I must have had the regex wrong.
<FromGitter> <Blacksmoke16> @jwoertink it can either be a string or regex
<FromGitter> <Blacksmoke16> i.e.`expect_raises(Exception, "Ops") { raise Exception.new("Ops") }`
<FromGitter> <Blacksmoke16> would test message is exactly `Ops`, or could do `expect_raises(Exception, /.*Ops.*/) { raise Exception.new("Ops") }` which would be like contains `Ops`
<FromGitter> <kinxer> @Blacksmoke16 Hey, serialization wizard, does Crystal have a way to serialize a class constant and verify its presence and equality during deserialization?
<FromGitter> <Blacksmoke16> i mean not by default but its possible to tap into the serialization process and add them/do your check there
<FromGitter> <Blacksmoke16> are you using JSON::Serializable?
<FromGitter> <kinxer> I am.
<FromGitter> <Blacksmoke16> oh sorry deserialization
<FromGitter> <Blacksmoke16> could you make a little example of what you're trying to do in the playground and i can take a look?
<FromGitter> <kinxer> Yeah, I'll try to work something up.
<FromGitter> <Blacksmoke16> 👌
<FromGitter> <kinxer> I know that constant access works a bit differently (it would `Example::TYPE`), but I think that gives a basic idea of what I want.
<FromGitter> <kinxer> I'm writing a GeoJSON (http://geojson.org/) parsing and creation library, and I've been using a standard assigned `getter`, but the string should really just be the same for every instance, so I'm using unnecessary memory.
<FromGitter> <Blacksmoke16> whats the expected behavior of deserializing that first object with the `type` field?
<FromGitter> <kinxer> Ideally, it would be to raise an error if the `type` field didn't match the value of `TYPE`.
<FromGitter> <Blacksmoke16> ah thats what i wanted to know
<FromGitter> <Blacksmoke16> sec
waheedi has quit [Quit: waheedi]
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6sj5
<FromGitter> <Blacksmoke16> that should do it?
<FromGitter> <Blacksmoke16> prob might even be able to to define that on a parent class and just would be inherited by other types
<FromGitter> <kinxer> That's cool. Thank you.
<FromGitter> <Blacksmoke16> np, ofc those errors would be at runtime
<FromGitter> <kinxer> You can even tweak it to work with `JSON::Serializable::Strict` and `JSON::Serializable::Unmapped`: https://play.crystal-lang.org/#/r/6sj8
<FromGitter> <kinxer> I mean, yeah. But that's gonna have to be the case when deserializing and serializing stuff anyway.
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab was doing something with instantiating a specific object based on the key of a field in the JSON as well, he might have some ideas as well since it seems to be a similar setup?
<FromGitter> <kinxer> I'd be interested to hear about that. My biggest hurdle with this library has been deserializing geometries whose `coordinates` fields have different levels of nested arrays (without requiring that `type` be the first field, which isn't supposed to be necessary when handling JSON).
<FromGitter> <Blacksmoke16> yea for sure, seems it would be quite helpful
alex2``3 has joined #crystal-lang
alex2`` has quit [Ping timeout: 258 seconds]
alex2``33 has joined #crystal-lang
alex2``3 has quit [Ping timeout: 250 seconds]
<FromGitter> <kinxer> Something to consider: your solution will always put the `type` field at the end of the serialized object, which is the opposite of where you usually want it. Again, it's JSON, so it "doesn't matter", but it's a lot easier to read (as a human) if the `type`is at the beginning.
<FromGitter> <Blacksmoke16> then you would have to implement your own `to_json` afaik
<FromGitter> <Blacksmoke16> since that method runs after the standard `to_json` @kinxer
<FromGitter> <kinxer> Yeah, I figured it would be something like that. For now I'm probably going to stick with a normal `getter`, but I'll have to think about this more.
<FromGitter> <Blacksmoke16> in *that* case you could still do what you want
<FromGitter> <Blacksmoke16> sec
<FromGitter> <kinxer> Oh, I already have an implementation with a normal `getter`.
<FromGitter> <kinxer> Technically it doesn't have `type` parameter checking, though.
<FromGitter> <kinxer> 'Cause I have an abstract `Geometry` superclass that uses the `type` to determine what subclass to instantiate.
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6sju 💥
<FromGitter> <Blacksmoke16> prob could also add that to the parent, to validate children?
<FromGitter> <Blacksmoke16> have have to wrap it in a macro hook tho so it uses the child's const
<FromGitter> <kinxer> That's pretty nice. It could go in an `inherited` macro.
<FromGitter> <Blacksmoke16> yea exactly
shmibs has left #crystal-lang ["WeeChat 2.4"]
hightower2 has joined #crystal-lang
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> @kinxer I'm home from work if you're still around
nathanj has quit [Ping timeout: 240 seconds]
nathanj has joined #crystal-lang
rohitpaulk has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
rohitpaulk has quit [Remote host closed the connection]