ruby is telling you that the x in that line does not refer to anything. You need ‘self’ instead of x.
Also, don’t ever post code again without proper indenting. In the future, paste your code in the window, then highlight it and select the proper code tags from the drop down list(you may have to hit the ‘Go Advanced’ button to see the Select Syntax drop down list), and the forum software will automatically preserve the indenting, like this:
class String
remove_method(:each)
end
class Object
def reach
if(x.respond_to?(:each))
self.each{|x| x.reach(yield)}
else
yield(self)
end
end
end