From: Robert Klemme Date: 2010-08-20T20:37:38+09:00 Subject: Re: function call using reflection 2010/8/20 Rajarshi Chakravarty : > Hi, > I get each part of the following command in a string at runtime > Mod1::Util.parser1("log.txt") > > So I have the following strings: > s1 = "Mod1" > s2 = "Util" > s3 = "parser1" > s4 = "log.txt" > > Now I want to prepare the command and execute it at runtime. > > Object::const_get(s1 + "::" + s2 + "." + s3 + "(\"" + s4 + "\")") > does not work. const_get will only resolve a constant (as the name indicates). You could either use eval instead but I recommend the more robust and secure version with const_get and send. Object::const_get(s1).const_get(s2).send(s3, s4) Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/