From: salamond Date: 2008-06-06T10:40:33+09:00 Subject: Re: variable in lambda many thanks for the help, Robert and Onur. I tried Onur's way, it works. But I don't quite get the later simpler method, I'll try it later. I'm using this method in UnitTest. Have you guys wondered, why Ruby Unit Test can't do something like this: class Test_${name} { def setup {} def test_${step1} {} def test_${step2} {} def teardown {} } most of my unit test cases are like something above, and I want to express all cases in data, automatically generate cases in the run time Do u think it's possible? JarodZZ~ On Fri, Jun 6, 2008 at 1:44 AM, Robert Klemme wrote: > On 05.06.2008 11:43, Onur Gungor wrote: >> >> a missing curly brackets. >> >>> acode = lambda { |c| lambda { >>> puts "i am a student in class " + c >>> }} >>> > > Much simpler > > irb(main):001:0> class F > irb(main):002:1> %w{a b c}.each {|c| define_method(c) { c }} > irb(main):003:1> end > => ["a", "b", "c"] > irb(main):004:0> F.new.a > => "a" > irb(main):005:0> F.new.b > => "b" > irb(main):006:0> F.new.c > => "c" > irb(main):007:0> > > Kind regards > > robert > >