<pawnbox>
I have config var that hash type (compile-time type is (Nil | String | Hash(String, String) | Hash(YAML::Type, YAML::Type) | Array(YAML::Type)))
<pawnbox>
I am not iterate over it.
<pawnbox>
*able
<pawnbox>
even if I check that iterate if config is a Hash
<BlaXpirit>
ugh
<BlaXpirit>
doesn't just YAML::Type work?
<pawnbox>
I am expecting to to be Hash mostly
<BlaXpirit>
this makes no sense to me
<pawnbox>
Well actually that is because Yaml.load return a hash.
<pawnbox>
and config is result of that.
askn has quit [Ping timeout: 252 seconds]
<pawnbox>
Lemme rephrase.
<pawnbox>
how do i iterate over a var which has compile-time type is (Nil | String | Hash(String, String) | Hash(YAML::Type, YAML::Type) | Array(YAML::Type)).
<pawnbox>
?
<pawnbox>
config.each {...} if config.is_a?(Hash) doesn't work for me.
askn has joined #crystal-lang
<pawnbox>
it says undefined method 'each' for Nil.
<BlaXpirit>
pawnbox, well normally you don't deal with such monstrosity
<askn>
Do you have any suggestions jhass
<BlaXpirit>
you should go further and elaborate on the use case
<jhass>
askn: make a hash to lookup at compile time or generate a case when dispatcher with a macro
<BlaXpirit>
pawnbox, hmm first of all use config.not_nil!.each
<pawnbox>
What exactly doesn't is_a? work with instance variable?
<pawnbox>
asterite:
<pawnbox>
*Why
<asterite>
Because if you do `if @a.is_a?(Hash)` and before executing the next line the program halts that thread and goes to another one and changes the value of @a, your program will behave in a wrong way
askn has quit [Ping timeout: 252 seconds]
<pawnbox>
Goes to another thread? Why?
<jhass>
in case it's multithreaded?
<jhass>
context switches can happen anywhere then
<pawnbox>
What i don't understand why would if @a.is_a?(X) cause a context switch?
wminor has quit [K-Lined]
mroth has quit [K-Lined]
iamstef has quit [K-Lined]
avdi has quit [K-Lined]
joshcarter has quit [K-Lined]
aemadrid has quit [K-Lined]
emmanueloga has quit [K-Lined]
danzilio has quit [K-Lined]
guilleiguaran__ has quit [K-Lined]
chrisseaton has quit [K-Lined]
victor_lowther has quit [K-Lined]
jwaldrip has quit [K-Lined]
<jhass>
they're not caused, they happen
<pawnbox>
ok. Guess i need to read up more on is_a?.
waj has joined #crystal-lang
chrisseaton has joined #crystal-lang
iamstef has joined #crystal-lang
emmanueloga has joined #crystal-lang
avdi has joined #crystal-lang
victor_lowther has joined #crystal-lang
mroth has joined #crystal-lang
wminor has joined #crystal-lang
koka has quit [Quit: Page closed]
aemadrid has joined #crystal-lang
nulpunkt has quit [Ping timeout: 245 seconds]
danzilio has joined #crystal-lang
guilleiguaran__ has joined #crystal-lang
joshcarter has joined #crystal-lang
jwaldrip has joined #crystal-lang
akwiatkowski has quit [Ping timeout: 246 seconds]
nulpunkt has joined #crystal-lang
Philpax has joined #crystal-lang
Philpax has quit [Ping timeout: 245 seconds]
waterlink has joined #crystal-lang
<asterite>
pawnbox: it's not something related to is_a?, it's how operating systems work. They schedule some time to one thread, once that time is up they go to the next thread and so on. It's out of our control to know *when* the OS decides to switch threads, so it can happen just after the is_a? check completed
sadin is now known as Sadin
<robacarp>
that is a fascinating constraint
<robacarp>
I hadn't considered that instance variables meant they could be volatile
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
shama has quit [Remote host closed the connection]
shama has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
trapped has joined #crystal-lang
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
diner has joined #crystal-lang
trapped has joined #crystal-lang
akwiatkowski has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
tomchapin has joined #crystal-lang
diner has quit [Quit: Page closed]
Philpax has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 265 seconds]
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]