allomov
8/11/2011 - 7:34 AM

fast way to blow your mind

fast way to blow your mind

class A
  def hello
    self.world
  end
  
  private
  
  def world
    puts "world"
  end
end
# it will raise exeption, 'cause private methods can't be evoked with reciever
A.new.hello rescue Exception

class B
  def hello
    self.world = "mind is blown"
  end
  
  private
  
  def world=(args)
    puts "and what did you expected ? it's Ruby )"
  end
end
# IT WORKS !!!
B.new.hello