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
ur5us has quit [Ping timeout: 264 seconds]
ur5us has joined #crystal-lang
ur5us_ has joined #crystal-lang
straight- has joined #crystal-lang
sorcus1 has joined #crystal-lang
avane_ has joined #crystal-lang
ur5us has quit [*.net *.split]
sorcus has quit [*.net *.split]
avane has quit [*.net *.split]
straight-shoota has quit [*.net *.split]
DeBot has quit [*.net *.split]
ur5us_ has quit [Ping timeout: 252 seconds]
Guest42 has joined #crystal-lang
Guest42 has quit [Client Quit]
fifr has quit [Quit: ZNC 1.8.2 - https://znc.in]
fifr has joined #crystal-lang
elf_fortrez has joined #crystal-lang
sorcus1 has quit [Quit: WeeChat 3.2]
sorcus has joined #crystal-lang
Elouin has joined #crystal-lang
avane_ is now known as avane
elf_fortrez has quit [Quit: Client closed]
elf_fortrez has joined #crystal-lang
elf_fortrez has quit [Quit: Client closed]
maria_elis has quit [Ping timeout: 268 seconds]
maria_elis has joined #crystal-lang
hightower2 has joined #crystal-lang
Guest67 has joined #crystal-lang
Guest67 has quit [Client Quit]
elf_fortrez has joined #crystal-lang
elf_fortrez has quit [Quit: Client closed]
elf_fortrez has joined #crystal-lang
<FromGitter> <alex-kampa> So far I've done some tests and do not see any performance issues
elf_fortrez has quit [Ping timeout: 246 seconds]
<FromGitter> <wyhaines> It can starve other threads even when doing IO. The contexts under which Crystal effectively yields back to the scheduler so that something else can run are extremely limited.cd/
<FromGitter> <alex-kampa> ``` a = ["string", 13, 787.to_i64] ⏎ puts typeof(a[0]) #=> (Int32 | Int64 | String)``` ⏎ ⏎ Why does this not give me String [https://gitter.im/crystal-lang/crystal?at=60d101f5f862a72a30c71056]
<FromGitter> <tenebrousedge> because you're not using a Tuple
<FromGitter> <tenebrousedge> Arrays are variable sized, any element can be any of the types within the array
<FromGitter> <tenebrousedge> Tuples are fixed size and work like you are expecting with regards to types
<FromGitter> <alex-kampa> Sure, but every individual element has its own definite type at any given time.
<FromGitter> <Blacksmoke16> The compiler isn't able to prove that
<FromGitter> <tenebrousedge> that's true of any union type
<FromGitter> <alex-kampa> Ok so at runtime I want to do something if an element is a string, and something else if it is a number. Are you saying I need to convert the array into a tuple? Or is there another way?
<FromGitter> <tenebrousedge> use a case statement
<FromGitter> <tenebrousedge> and think about whether you really want an array with that union type in the first place
<FromGitter> <alex-kampa> @tenebrousedge - re case statement - ok but case what?
<FromGitter> <tenebrousedge> `case foo; when Int32 then do_stuff; when String then do_other_stuff`
<FromGitter> <Blacksmoke16> `a[0]` specifically
<FromGitter> <alex-kampa> Ok thanks that works - I was trying with typeof(a[0]) == "String" which didn't work.
ur5us_ has joined #crystal-lang
<FromGitter> <alex-kampa> Anyway, the function I was actually looking for was ".is_a?" - had forgotten about it - but the case construction which uses is_a? implicitly is indeed more elegant
<FromGitter> <alex-kampa> Thanks again @tenebrousedge and @Blacksmoke16 !
deavmi_ has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
hightower2 has quit [Ping timeout: 265 seconds]
Chioque has joined #crystal-lang
Chioque has quit [Client Quit]
Chioque has joined #crystal-lang
Chioque has quit [Remote host closed the connection]
Chioque has joined #crystal-lang
Chioque has quit [Client Quit]