I have a class like this:
class Control
attr_accessor :name, :parent, :children
alias [] getChild
def initialize(name)
self.name = name
@children = Hash.new
end
def addChild(child)
child.parent = self
@children[child.name] = child
end
def getChild(name)
@children[name]
end
end
So i want to alias method named getChild as []. But Ruby says "undefined
method `getChild' for class `Control'". How can I make such alias?
···
--
Posted via http://www.ruby-forum.com/.