From: Sam Larbi Date: 2007-11-20T06:09:39+09:00 Subject: using lambda, binding happens immediately? ------=_Part_3492_29416193.1195506581679 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I have this code: require 'test/unit' require 'leapyear' class LeapYearTest < Test::Unit::TestCase def setup @ly = LeapYear.new end def LeapYearTest.generate_tests filename = "testdata.dat" file = File.new(filename, "r") file.each_line do |line| year, is_leap = line.split; code = lambda { assert_equal(is_leap.downcase=="true", @ly.isleap?( year.to_i)) } define_method("test_isleap_" + year, code) end file.close end end What I want to know is why when I use define_method("name") {block;} instead of define_method("name", lambda{block}) the binding seems to happen later (after the each_line loop)? Is there a reason behind that? Thanks, Sammy Larbi ------=_Part_3492_29416193.1195506581679--