From: James Edward Gray II Date: 2007-01-17T23:16:44+09:00 Subject: Re: Passing math method to another method? On Jan 17, 2007, at 8:10 AM, Neutek wrote: > I'm trying to figure out how to pass methods such as: > +, -, **, ^ > to a method and evaluate. > > For example, > > def test(a, b, to_do) > return a.send(to_do(b)) > end > > > puts test(1, 2, "+") #should return 3 > puts test(3, 3, "^") #should return 0 > puts test(3, 3, "**") #should return 27 > > any help would be appreciated. >> def test(a, b, meth) >> a.send(meth, b) >> end => nil >> test(1, 2, :+) => 3 >> test(3, 3, :^) => 0 >> test(3, 3, :**) => 27 Hope that helps. James Edward Gray II