For those who don’t know, it has been 3 months since I am working with Slideshare. I have never written code in ruby before Slideshare and always involved in development with low-level languages like C/C++. Here I have a chance of writing code in Ruby and I’m loving it.

Since few days, we were wondering why our Cache was not being flushed even we have done everything right over there. What we were doing was to check a Boolean variable (true, false, nil) and based on that we were deciding to flush cache or not. The code used to look as below:
var = true

#it wasn't working
if var == 1
Flsuh_data_from_Cache
end

We were suspecting everything ok since we start looking into the problem and was wondering why this flush request is not working. Ultimately after some real time debugging, the reason of failure was that in Ruby TRUE is not equal to 1. I was surprised that many people didn't know this fact and use this kinda check at many places. Finally, we have to change our code like below to get it in action.
var = true

#it worked
if var
Flsuh_data_from_Cache
end

After seeing this. Again this isn’t the only thing that surprised me but many more similar things are there to baffle you.

PS: I am still looking for some good resource on how variables are stored in memory in Ruby. If someone can get me an idea of that, I will be highly grateful to him/her.

Subscribe - To get an automatic feed of all future posts subscribe here, or to receive them via email go here and enter your email address in the box. You can also like us on facebook and follow me on Twitter @akashag1001.