RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.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
<FromGitter> <Blacksmoke16> @aboeglin you could just do `def initialize(@name : String)`
<FromGitter> <Blacksmoke16> which will handle setting it as well
<FromGitter> <Blacksmoke16> is there a way to iterate over the keys on an annotated ivar?
<FromGitter> <Blacksmoke16> @asterite ^
non-aristotelian has quit [Quit: non-aristotelian]
Heaven31415 has quit [Quit: Leaving]
tilpner has quit [Ping timeout: 245 seconds]
tilpner has joined #crystal-lang
<FromGitter> <drujensen> @vladfaust the code is very clean. nice job.
<raz> what is it with gitter in the crystal community? :/ of all available chat options (irc, slack) it seems the worst by far
<FromGitter> <fridgerator> you're messaging from irc?
<raz> yup, there's a bridge-bot, but it's not very pleasant (nick completion doesn't work etc.)
<FromGitter> <fridgerator> has worked ok for me for the last 2ish years
<raz> well, i just checked and there seem to be actually more ppl on irc than on gitter. just the gitter ones are a lot more active
<raz> maybe i'm just nitpicking ;)
<FromGitter> <fridgerator> There are a lot of suggestions to switch to various other chat mediums
<FromGitter> <fridgerator> the core team just wants to stay with gitter *shrugs*
<FromGitter> <fridgerator> I dont really care, they essentially all do the same thing
<raz> yea, i just miss my nick completion... for me you are displayed as FromGitter, it also makes it tiresome to follow convos
<FromGitter> raz, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<FromGitter> <fridgerator> that is annoying
<FromGitter> <fridgerator> I think if the community gets bigger, they willl have to change something
<raz> yep, it's not a big deal anyway. just a tiny pebble in my shoe. i agree so much with where crystal is headed, all their choices and prios seem to be spot on. but gitter for chat? maybe i'm getting old... ;)
<FromGitter> <fridgerator> what brought you to crystal?
<FromGitter> <proyb6> Is it a good idea if we could hardcode module with versioning to know which API came from which modules? ⏎ ⏎ 1) A bit verbose namespace help coders to identify accurately than assuming the API came from other modules or core libraries (Ruby vs RoR api) ⏎ 2) Test both old and new modules to ensure it generate exact results ⏎ 3) We could quickly upgrade our existing code without breaking the old API ...
<raz> fridgerator don't remember how i initially discovered crystal, but it immediately stuck. apart from the basic premise ('high speed ruby') crystal gets so many auxiliary things right, it's pure bliss. e.g. in this day and age it should be a no-brainer that having a solid packaging system (shards) is essential. but as we all now, many other languages still haven't gotten the memo...
<raz> i also love how the compiler spits out tutorials instead of error messages. i don't think i have seen a compiler be _this_ helpful before (most don't even try)
<FromGitter> <proyb6> In an analogy, I could change/add many small parts rather than change the large parts of the machine
return0xe has joined #crystal-lang
return0e has quit [Ping timeout: 252 seconds]
<FromGitter> <fusillicode_twitter> > @FromIRC ⏎ *<raz>* fridgerator don't remember how i initially discovered crystal, but it immediately stuck. apart from the basic premise ('high speed ruby') crystal gets so many auxiliary things right, it's pure bliss. e.g. in this day and age it should be a no-brainer that having a solid packaging system (shards) is essential. but as we all now, many other languages still haven't gotten the
<FromGitter> ... memo... ⏎ *<raz>* i also love how the compiler spits out tutorials instead of error messages. i don't think i have seen a compiler be *this* helpful before (most don't even try) ⏎ ⏎ True stories...the 2nd part in particular...ಠ_ಠ Scala [https://gitter.im/crystal-lang/crystal?at=5bc19d4a271506518d042db8]
<FromGitter> <fusillicode_twitter> thanks @FromIRC I got it...
<FromGitter> <aboeglin> @vladfaust what's the app about ?
raz has left #crystal-lang ["*fump*"]
rohitpaulk has joined #crystal-lang
return0xe has quit [Remote host closed the connection]
return0xe has joined #crystal-lang
<FromGitter> <fusillicode_twitter> Guys I just wanted to share a possible problem I've found with the Halite shard 👉 https://github.com/icyleaf/halite/issues/41
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
ashirase has quit [Ping timeout: 252 seconds]
<FromGitter> <chussenot> Yop stupid question, it's maybe in the doc...
<FromGitter> <chussenot> how to snakecase a string ?
<FromGitter> <fusillicode_twitter> I think that the stdlib doesn't have it @chussenot 🤔
<FromGitter> <chussenot> OK ;)
<FromGitter> <fusillicode_twitter> but I recall having seen a shard giving that ;)
<FromGitter> <chussenot> I will take a look at shards
<FromGitter> <fusillicode_twitter> let me check
<FromGitter> <chussenot> cool
ashirase has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter> <fusillicode_twitter> here you go https://github.com/phoffer/inflector.cr
<FromGitter> <chussenot> perfect
<FromGitter> <fusillicode_twitter> I think that it is also used by many other shards underline ;)
<FromGitter> <fusillicode_twitter> Like Crecto for example
<FromGitter> <chussenot> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bc1b8a21e23486b93b68345]
<FromGitter> <chussenot> Add finally @fusillicode_twitter .... how to convert a string to symbol ?
<FromGitter> <chussenot> `key ` should be a symbol here...
<FromGitter> <fusillicode_twitter> oh gosh macro
<FromGitter> <chussenot> :|
<FromGitter> <chussenot> yeah I know...
<FromGitter> <fusillicode_twitter> Well it's not about macros themselves, it's only that I'm still a noob from that point of view XD
<FromGitter> <fusillicode_twitter> anyway what to you think about this https://play.crystal-lang.org/#/r/5851
<FromGitter> <chussenot> I want a dynamic NameTuple with all classes that inherit from the `Gitlab::Event` abstract class
<FromGitter> <fusillicode_twitter> uhmmm
<FromGitter> <chussenot> It's why I use the `macro inherited` hook
<FromGitter> <fusillicode_twitter> got it
<FromGitter> <fusillicode_twitter> but as I recall correctly named tuples are meant to be "static"
<FromGitter> <fusillicode_twitter> I mean it sounds to me that this is a good scenario for an Hash rather than a NamedTuple 🤔
<FromGitter> <fusillicode_twitter> Cause you're actually don't know all the possible classes that inherit from the `Gitlab::Event`
<FromGitter> <chussenot> Yeah.... I use the work dynamic... but it's a compile time... sorry for that mistake
<FromGitter> <chussenot> Ok I will take a look at this way...
<FromGitter> <chussenot> Cheers
<FromGitter> <fusillicode_twitter> Well let me know if you manage to achieve your goal :D
<FromGitter> <chussenot> for sure :)
<FromGitter> <chussenot> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bc1befcc08b8b30670a588d]
<FromGitter> <chussenot> Yep thats better with a `Hash`
<FromGitter> <fusillicode_twitter> great! I'm happy that it worked :)
<FromGitter> <chussenot> `Events = {} of String => Gitlab::Event.class`
<FromGitter> <chussenot> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bc1bf3e435c2a518e9cc273]
DTZUZO_ has quit [Ping timeout: 252 seconds]
<FromGitter> <ljuti> I have a `Array(Int32 | Nil)` and I want to compare the elements when they’re both `Int32`. Doing `a[index] <=> b[index]` doesn’t work because Int32 doesn’t have ‘<=>(Int32 | Nil)` method. How do I avoid polluting the Int32 class?
<FromGitter> <fusillicode_twitter> Wrap it 🤔
<FromGitter> <fusillicode_twitter> I mean with a new custom type :)
<FromGitter> <ljuti> I’m very tempted to just do .to_s.to_i :)
<FromGitter> <chussenot> `Array(Int32?)` ?
<FromGitter> <fusillicode_twitter> > I’m very tempted to just do `.to_s.to_i` :) ⏎ ⏎ well...I'll be tempted too XD
<FromGitter> <j8r> @ljuti if there is a Nil, there is a reason why – handle it
<FromGitter> <ljuti> @j8r I’m handling it beforehand, but then I want to know which one of them integers is bigger
<FromGitter> <fusillicode_twitter> > @ljuti if there is a Nil, there is a reason why – handle it ⏎ ⏎ wise words :)
<FromGitter> <ljuti> Once I know both of them are integers
<FromGitter> <ljuti> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bc1d27d3844923661314e59]
<FromGitter> <ljuti> This is what I’d like it to be
<FromGitter> <j8r> you even drop the nil (if there are no booleans in the story)
<FromGitter> <j8r> there is two problems
<FromGitter> <j8r> first, the type isn't restricted - to do so assign to local variables
<FromGitter> <j8r> then, you access one time the value from the hash, and then again a second time after the `else`
<FromGitter> <ljuti> Ahh, good points
<FromGitter> <ljuti> Thanks, let me rewrite tihs
<FromGitter> <j8r> before the `if`, do `a = a[i]` and `b = b[i]`
<FromGitter> <ljuti> Uhhuh
<FromGitter> <j8r> then you're good :)
<FromGitter> <j8r> (sorry I've messed up the var name)
<FromGitter> <ljuti> @j8r Fixed it, thanks!
<FromGitter> <kingsleyh> hi what does this mean?
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bc1e1b2435c2a518e9da8b3]
<FromGitter> <kingsleyh> do I need to install some library?
<FromGitter> <girng> did you compile with --static?
<FromGitter> <asterite> Ugh, writing Go gets the job done but it's so painful. Every time has me writing lots of boilerplate code. And when parsing JSON... there's no way to have required fields, everything is optional. wtf?
Yxhuvud has joined #crystal-lang
jhass has quit [Ping timeout: 252 seconds]
jhass has joined #crystal-lang
<FromGitter> <S-YOU> protobuf3 is like that too
<FromGitter> <S-YOU> I am also doing Go(/gRPC) at work recently
<FromGitter> <S-YOU> And I gave up DRY
<FromGitter> <fusillicode_twitter> I just want to share my brief experience with HTTP clients in Crystal land :) ⏎ ⏎ 1) stdlib HTTP::Client: rich of features but still pretty bare bones. As should it be! ;) ⏎ 2) Halite: a beast...tons of features but didn't found a way to properly construct an "independent" request object, execute it and get back a response object. Moreover I may have found a bug pertaining the JSON
<FromGitter> ... serialization. ⏎ 3) Cossack: well designed from an architectural point of view and seems pretty extensible. I still miss some features ... [https://gitter.im/crystal-lang/crystal?at=5bc1fe04e65a634336d109c8]
<FromGitter> <chussenot> Thx
<FromGitter> <fusillicode_twitter> Btw all the shards are pretty well written and I really loved to deep dive in their sources!
<FromGitter> <j8r> @fusillicode_twitter thanks for the detailed feed-back!
<FromGitter> <fusillicode_twitter> @j8r @chussenot thanks you guys for all your support in this channel! 🤗 ⏎ Btw I feel that the feedback could have been much more detailed but unfortunately I'm still a noob with Crystal and in the end didn't had so much time to play around with the mentioned shards 😅
<FromGitter> <chussenot> a sharing `Crest` ;)
<FromGitter> <fusillicode_twitter> I still hope that it may helps :)
<FromGitter> <chussenot> cool shard
<FromGitter> <j8r> sadly Crest has a bit too Rubyism for me
<FromGitter> <fusillicode_twitter> I think I may also be biased by that XD
<livcd> asterite: yeah writing go is not a thrilling experience
<livcd> just make Crystal usable for the rest of us :33
<FromGitter> <j8r> I don't see the point of all of https://github.com/mamantoha/crest/search?q=Symbol&unscoped_q=Symbol : `Hash(Symbol, Whatever)`?!
<FromGitter> <j8r> Except that, the shard provides nice HTTP features not available out there
<livcd> whenever i have to compile llvm for crystal it kills my mac..ehh
<FromGitter> <fusillicode_twitter> livecd I've tried yesterday and I killed the compilation after an hour at 75 degrees...
<FromGitter> <fusillicode_twitter> XD
<FromGitter> <fusillicode_twitter> @j8r I get your point ;)
<livcd> i wish someone would invest 1bn$ in crystal
<FromGitter> <fusillicode_twitter> +1 ☝
<FromGitter> <bajro17> livcd I swear if I have that much money I will do it instantly
<livcd> sell your kidneys. support crystal
<FromGitter> <bajro17> hahahah dont work good anymore
<FromGitter> <proyb6> I find HTTP server barebones is on par with Golang but slower when we created Get, who knows what is the better
<FromGitter> <proyb6> way?
Heaven31415 has joined #crystal-lang
<Heaven31415> Hi
<FromGitter> <kingsleyh> @girng nope just crystal run src/main.cr
<FromGitter> <kingsleyh> I think I'm missing some libraries or something
<FromGitter> <kingsleyh> works fine on my other mac just not this mac
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/58a5 am i missing something as to why this doesnt work?
Heaven31415 has quit [Quit: Leaving]
<FromGitter> <S-YOU> I don't think you can pass Type as Value like that
<FromGitter> <S-YOU> may be you can use `typeof(expected)`, but I guess it is not what you expected.
<FromGitter> <Blacksmoke16> hm
<FromGitter> <Blacksmoke16> yea would always be `Class`
<FromGitter> <Blacksmoke16> yea looks like you cant have a dynamic `is_a?` with variables
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/58am
<FromGitter> <Blacksmoke16> intended or bug is the question now, which i never know the answer to :p
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/58at looks like a decent alternative
<FromGitter> <fenicks> What is the correct way to remove leading zero in float: 1.4500000000 => 1.45 ? Need I to use string to do that ?
<FromGitter> <S-YOU> Actually, there is some way to pass Type/Class to a function, but not always. ⏎ https://play.crystal-lang.org/#/r/58bd
<FromGitter> <aboeglin> Well, the 0 are in a String already no ? In the float world it comes down to precision, but the 0 aren't coded. 1.45 will always have the same binary representation.
<FromGitter> <Blacksmoke16> could prob use round?
<FromGitter> <aboeglin> https://i.stack.imgur.com/WENuF.png
<FromGitter> <aboeglin> So here, whetever you do, if you want to hold 1.45, you won't change the bytes. So it's about how you represent it on a String from my understanding.
<FromGitter> <fenicks> With precision, If the number is 1.45600 I want 1.456 and not 1.46. The best way is probably to use the string representation. Ok.
<FromGitter> <fenicks> @Blacksmoke16 round or trunc remove the decimal part
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/58bj looks like it already strips the extra 0s
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/58bl
<FromGitter> <Blacksmoke16> doesnt look like it, ofc if the value has more digits than you are rounding it would be slightly off
<FromGitter> <fenicks> @Blacksmoke16 I'll try to investigate if I have some javascript around there or it's pure crytsal
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <fenicks> @Blacksmoke16 Oh my bad, JS was there. Now i have to deal with JS currency format.
<FromGitter> <fenicks> Thnks guys
<FromGitter> <Blacksmoke16> np, that would do it
rohitpaulk has joined #crystal-lang
ashirase has quit [Quit: ZNC - http://znc.in]
ashirase has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
Heaven31415 has joined #crystal-lang
<Heaven31415> Hi
ashirase has quit [Read error: Connection reset by peer]
ashirase has joined #crystal-lang
ashirase has quit [Ping timeout: 244 seconds]
ashirase has joined #crystal-lang
<FromGitter> <Blacksmoke16> o/
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/58cb
<FromGitter> <Blacksmoke16> that regex doesnt look right...
<FromGitter> <Blacksmoke16> or does that represent something
<FromGitter> <r00ster91> yes it does. i stands for ignore case, ms for multiline and x for extended: ⏎ https://github.com/crystal-lang/crystal/blob/391785249f66aaf5929b787b29810aeb4af0e1e8/src/regex.cr#L535
<FromGitter> <Blacksmoke16> 👍 thanks
ashirase has quit [Ping timeout: 245 seconds]
<FromGitter> <girng> @kingsleyh hmm yeah openssl or something. what's your os btw?
<FromGitter> <girng> i tried go before, but went back to crystal cause arthritis
<FromGitter> <girng> very unpleasant experience with that language tbh the letter casing is detrimental for me
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer i made a thing
<FromGitter> <Blacksmoke16> pretty fancy if i say so myself ;P
<FromGitter> <girng> no idea but i starred it
ashirase has joined #crystal-lang
<FromGitter> <Blacksmoke16> main benefits of it are like if you are building/working with JSON apis
<FromGitter> <girng> interesting, yeah anything to make json easier for dev i like
<FromGitter> <Blacksmoke16> esp helps with JSON api in crystal and like some frontend js framework, so you can easily validate the json data coming to crystal api while also deserializing it into an obj
<FromGitter> <Blacksmoke16> can also catch the exception and call `to_json` on it and it'll return json string like `{"code": 400, "message":"Validation tests failed", "errors': ["`username` should not be blank", "The size of `password` should be between 8 and 25"]}`
<FromGitter> <fridgerator> @Blacksmoke16 nice, I like it
<FromGitter> <Blacksmoke16> thanks :)
ashirase has quit [Ping timeout: 252 seconds]
<FromGitter> <Blacksmoke16> got everything tested fairly well, but any issues feel free to make one
<FromGitter> <Blacksmoke16> still some docs to do and such but core is there
ashirase has joined #crystal-lang
DTZUZO_ has joined #crystal-lang
ashirase has quit [Ping timeout: 252 seconds]
ashirase has joined #crystal-lang
ashirase has quit [Ping timeout: 268 seconds]
moei has quit [Quit: Leaving...]
ashirase has joined #crystal-lang