Last week I was debugging a problem for our production servers. The code there is in ruby.

I encountered following lines while debugging:

suffixes= “some string”

suffixes.each do |suffix|

Do some operation on suffix


After reading this code, I was pretty surprised how this is running properly, coz each operation is for arrays and here ‘suffixes’ is a string. (Actually ‘suffixes’ was supposed to be an array but in few test cases, it was coming as string.) I tried to run the same code on my local machine and it threw following error on my face.

NoMethodError: undefined method `each' for "akash":String

from (irb):13

I was very much surprised with the different results on my local machine and on server. Then I checked the version of ruby installed on both the machines and that disclosed the mystery. On the server, it was 1.8.6 and that was working fine (though wrong). While on my local machine it was 1.9.2dev, this bug seems to be corrected in new version.

A few days ago, we were planing to upgrade to new version of ruby, but after this incidence, we pushed our plans for some time. These kinds of errors will make our life hell until we have a thorough investigation of such differences between the two versions.

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.