G
Gavin Kistner
#Works
class Foo1
def [](x)
#...
end
end
#Syntax Error
class Foo2
def bar[](x)
#...
end
end
Is there no way to define a method that has a name and [] in it, to be
able to do something like:
myObj = Foo.new
puts myObj.bar[12]
....without having to create a new class for bar and define the [] method
in that class?
class Foo1
def [](x)
#...
end
end
#Syntax Error
class Foo2
def bar[](x)
#...
end
end
Is there no way to define a method that has a name and [] in it, to be
able to do something like:
myObj = Foo.new
puts myObj.bar[12]
....without having to create a new class for bar and define the [] method
in that class?