From: nobu@... Date: 2006-10-04T09:17:58+09:00 Subject: Re: eval confusion Hi, At Wed, 4 Oct 2006 08:00:32 +0900, Paolo Negri wrote in [ruby-talk:217920]: > #!/bin/ruby > class DefMethod > M_COLLECTION = ('a'..'c') > M_COLLECTION.each do |alpha| > define_method(alpha) { > block_given? ? puts(yield(alpha)) : puts(alpha) This block_given? sees the context where define_method is called, that is defining DefMethod and always false. > } > end > end In 1.9, you have to write as: > define_method(alpha) {|&block| > block ? puts(yield(alpha)) : puts(alpha) > } No way in 1.8. -- Nobu Nakada