> You cannot use @attr, @attr is reserved for instance variables. Also, it's > a bad idea to use instance variables (@tmparray, @tmphash) as temporary > variables. Gotcha there, I wasn't planning to, it was more to make the variable more obvious in the example. > It's a one liner: > objects.sort_by {|o| o.send(attr)} Exactly what I needed, thanks... Now we're just looking at something like: def sort_obj(objects,attr) objects.sort_by {|o| o.send(attr)} end -- View this message in context: http://www.nabble.com/Evaluating-the-string-in-a-variable-to-use-as-a-method-name-t1292849.html#a3442515 Sent from the ruby-talk forum at Nabble.com.