ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | 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
notzmv has joined #crystal-lang
renich has quit [Quit: Leaving]
ur5us has quit [Ping timeout: 252 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 256 seconds]
Sankalp has quit [Ping timeout: 256 seconds]
Sankalp has joined #crystal-lang
HumanG33k has quit [Ping timeout: 252 seconds]
jmdaemon has quit [Ping timeout: 256 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
HumanG33k has joined #crystal-lang
Vexatos has quit [Quit: Client Quit]
Vexatos has joined #crystal-lang
notzmv has quit [Ping timeout: 260 seconds]
_ht has joined #crystal-lang
<yxhuvud> sigpwr seems to happen on power failure. I hadn't seen that one before.
<FromGitter> <azurelmao> What am I defining the initial capacity for if I can't use it like this? ⏎ https://carc.in/#/r/e78e
<FromGitter> <Blacksmoke16> it allocates memory such that it could fit 100 `Int32` values
<FromGitter> <azurelmao> So in order to skip past indexes I first have to fill the array with some value?
<FromGitter> <Blacksmoke16> there's another overload that allows you to initialize each index to some value if you want
<FromGitter> <azurelmao> Yeah ik, I had just hoped there would be a more convienent way to do it
<FromGitter> <Blacksmoke16> more convenient how?
<FromGitter> <Blacksmoke16> or backing up, what end result are you wanting?
<FromGitter> <azurelmao> It's just that I have a class which adds itself to a class var on init ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=638f9239c27b3d278f26c447]
<FromGitter> <azurelmao> so now I have to check whether the id is 0
<FromGitter> <azurelmao> in order to fill the array
<FromGitter> <Blacksmoke16> are they instantiated in order? i.e. is it possible the first instance has an `@id` of `10` and the next `1` or is it always going to go in order?
<FromGitter> <Blacksmoke16> `0, 1, 3, ...`
<FromGitter> <Blacksmoke16> `0, 1, 2, ...`*
<FromGitter> <azurelmao> they won't be in order
<FromGitter> <Blacksmoke16> `Hash(Int32, self).new` then?
<FromGitter> <azurelmao> Oh, I haven't thought of that
<FromGitter> <azurelmao> I'll try it
<FromGitter> <Blacksmoke16> seems like a more reasonable data model if you just want to store objects with a numerical key
<FromGitter> <azurelmao> btw, this is unrelated to my previous question I'm just curious, but is there a literal for object instantiation? Something like: ⏎ ⏎ ```foo = Foo{id: 1}``` ⏎ ⏎ Which would bypass the initialize method and let you assign the properties by hand [https://gitter.im/crystal-lang/crystal?at=638f93f7c27b3d278f26c729]
<FromGitter> <Blacksmoke16> no
<FromGitter> <azurelmao> I see
<FromGitter> <Blacksmoke16> unless you make everything nilable and do something like: ⏎ ⏎ ```foo = Foo.new ⏎ foo.id = 1 ⏎ ...``` [https://gitter.im/crystal-lang/crystal?at=638f9433280bbe4693c649b4]
<FromGitter> <Blacksmoke16> but ofc, having a proper constructor is usually the better way
<FromGitter> <Blacksmoke16> i.e. `Foo.new 1` or `Foo.new id: 1`
<FromGitter> <azurelmao> I usually avoid Nilable types, because of the trouble they cause
<FromGitter> <azurelmao> Anyways, thank you for helping me!
<FromGitter> <Blacksmoke16> np
<FromGitter> <Blacksmoke16> actually, not exactly what you want, but you could look into https://crystal-lang.org/reference/1.6/syntax_and_semantics/literals/hash.html#hash-like-type-literal
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
FromGitter has joined #crystal-lang
_ht has quit [Quit: _ht]
jmdaemon has joined #crystal-lang
<SamantazFox> For anyone interested: I've been doing my Advent of Code in Crystal this year ^^ https://github.com/SamantazFox/AoC-2022
ur5us has quit [Ping timeout: 260 seconds]