<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>
<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]