I am currently playing around with Ruby 2.0. I wanted to look into
Refinements and here is what I came up with:
refine Hash do
This is basically how it’s described everywhere.
However when I run this code, I’ll get that error:
[~]$ ruby refinements.rb
refinements.rb:2: warning: Refinements are experimental, and the
behavior may change in future versions of Ruby!
<class:MyTestClass>': undefined methodusing’ for
from refinements.rb:9:in `’
It only works when I move the ‘using RefinementTest’ one level up (in
the main namespace). But isn’t that the same as monkeypatching the Hash
class in the first place?
Or am I doing something fundamentally wrong?
I used 2.0.0-rc1