From: mark sparshatt Date: 2005-04-19T01:41:52+09:00 Subject: Re: object.["somepropertyOrmethod"] == object.somepropertyOrmethod ? falcon wrote: > Does Ruby allow javascript like invocation of methods (or access to > properties) like this: > someProperty = "nameOfStudent" > Object[someProperty] > > rather than just Object.nameOfStudent? The way to do this would be to use the send method Object.send(someProperty) Or you could define a [] method for your class def [](propertyname) self.send(propertyname) end then you'd be able to use Object[someProperty] > > I need something like this because how an object is manipulated depends > on runtime...basically it will be an experimental database system so > users will be able to manipulate data in any way they desire. > Iterators and lambda like functions make this very easy already. > > Also, is there a limit to how deep one can do recursion? Recursion can > easily cause stack overflow error in Java, but some languages don't > have that problem (I guess it is called tail call optimization). > Ruby doesn't currently use tail call implementation so there is a limit to recursion. IFAIK this'll be changed in Rite. HTH -- Mark Sparshatt