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
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 260 seconds]
hightower4 has joined #crystal-lang
hightower3 has quit [Ping timeout: 256 seconds]
hightower4 has quit [Ping timeout: 256 seconds]
irc_user has quit [Quit: Connection closed for inactivity]
ur5us has quit [Ping timeout: 246 seconds]
rocx has left #crystal-lang [ERC 5.4 (IRC client for GNU Emacs 28.1)]
straight-shoota has quit [Quit: ZNC 1.8.2 - https://znc.in]
straight-shoota has joined #crystal-lang
Starfoxxes has joined #crystal-lang
Starfoxxes has quit [Max SendQ exceeded]
_ht has joined #crystal-lang
Starfoxxes has joined #crystal-lang
Starfoxxes has quit [Max SendQ exceeded]
_ht has quit [Quit: _ht]
irc_user has joined #crystal-lang
<FromGitter> <vegah> Hi, new to crystal - is there a way in spec to test an array, or do you just use the index like this: ⏎ ⏎ ``` a.@tokens[0].@something.should eq("something")``` [https://gitter.im/crystal-lang/crystal?at=6389d4c115a3885c70197339]
luna has joined #crystal-lang
luna has left #crystal-lang [#crystal-lang]
irc_user has quit [Quit: Connection closed for inactivity]
<jhass[m]> A bit hard to judge from the example what you want, but you could for example a.map {|x| x.something }.should ["something1", "else"]
<FromGitter> <djberg96> @Blacksmoke16 in the end I punted on that, and just look for double zeroes, seems to pass :)
jmdaemon has quit [Ping timeout: 255 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
taupiqueur has quit [Ping timeout: 256 seconds]
taupiqueur has joined #crystal-lang
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
repo1 has quit [Ping timeout: 255 seconds]
repo1 has joined #crystal-lang
repo1 has quit [Ping timeout: 260 seconds]
Starfoxxes has joined #crystal-lang
_ht has joined #crystal-lang
jmdaemon has joined #crystal-lang
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
Sankalp has quit [Ping timeout: 252 seconds]
Sankalp has joined #crystal-lang
_ht has quit [Remote host closed the connection]
hightower2 has joined #crystal-lang
<FromGitter> <rjnienaber> when pattern matching an array, is it possible to capture values? e.g. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=638a82224cb5585f965fe6e8]
<FromGitter> <Blacksmoke16> prob a good usecase for `#sum`?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=638a831b8319db70990bdc52]
<FromGitter> <Blacksmoke16> something like that?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=638a83bcbdd9d94eca372f88]
<FromGitter> <rjnienaber> probably better to give my whole advent of code solution :D ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=638a84e4f0973a41eb22eba5]
<FromGitter> <rjnienaber> i'm trying to get rid of that `opponent, outcome = line.split` line
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
taupiqueur has quit [Ping timeout: 252 seconds]
alexherbo2 has quit [Ping timeout: 260 seconds]
<FromGitter> <Blacksmoke16> whats each line look like?
<FromGitter> <rjnienaber> ```A Y ⏎ B X ⏎ C Z``` [https://gitter.im/crystal-lang/crystal?at=638a89424abb3f46849fb5b1]
<FromGitter> <Blacksmoke16> sec
alexherbo2 has joined #crystal-lang
taupiqueur has joined #crystal-lang
<FromGitter> <Blacksmoke16> you going for performance or readability?
<FromGitter> <rjnienaber> readability
<FromGitter> <Blacksmoke16> okay in that case id start by doing `total = ARGF.each_line.sum do |line|` instead
<FromGitter> <Blacksmoke16> other than feels pretty good?
alexherbo2 has quit [Ping timeout: 260 seconds]
taupiqueur has quit [Ping timeout: 260 seconds]
<FromGitter> <rjnienaber> yeah, it does. i was curious if you can capture values while pattern matching but i'm guessing that's a no?
<FromGitter> <Blacksmoke16> not that im ware of. it is possible to use tuple literals with a case, but not sure that would work with arrays, which is what `.split` returns
hightower2 has quit [Read error: Connection reset by peer]
alexherbo2 has joined #crystal-lang