Plough => Ruby

Journey through ruby

In Ruby2, Inspect Independent of To_s

Ruby 2.0.0 has been released and there are a lot of new things, for example, keyword arguments, TracePoint API, DTrace and so on. Here’s Ruby NEWS file, and some new features in Ruby 2.

One thing to add to that list is that the behaviour of inspect is no longer dependent on to_s. In Ruby 1.9, if to_s was overridden inspect would just execute that code. But in Ruby 2.0, to_s overriding doesn’t affect inspect anymore. Here’s code example for Ruby 1.9.3 and Ruby 2