yarv-dev:812
From: sheepman <sheepman sheepman.sakura.ne.jp>
Date: Sun, 5 Feb 2006 00:42:41 +0900
Subject: [yarv-dev:812] Re: class_eval in method scope doesn't define methods
こんばんは、sheepmanです。 On Sun, 5 Feb 2006 00:28:06 +0900 sheepman <sheepman sheepman.sakura.ne.jp> wrote: > こんばんは、sheepman です。 > メソッドスコープ内で class_eval が正常に働きません。 > 以下のようにしても、メソッド hoge が定義されません。 > hoge は A のクラスメソッドとして定義されてしまうようです。 $ cat t.rb class A end def define_method A.class_eval %{ def hoge p "hoge" end } end define_method() A.hoge $ ./miniruby -v t.rb ruby 1.9.0 (2005-11-18) [i686-linux] YARVCore 0.3.3 (rev: 366) [opts: ] "hoge" ruby-1.9 では当然メソッドエラーになります。 $ ruby-1.9 -v t.rb ruby 1.9.0 (2005-12-30) [i686-linux] t.rb:13: undefined method `hoge' for A:Class (NoMethodError) -- sheepman / TAMURA Takashi sheepman sheepman.sakura.ne.jp http://sheepman.parfait.ne.jp/ -- ML: yarv-dev quickml.atdot.net 使い方: http://www.atdot.net/~ko1/quickml
809 2006-02-05 00:28 [sheepman sheepman.sa] open> class_eval in method scope doesn't define methods -> 812 2006-02-05 00:42 ┣[sheepman sheepman.sa] Re: class_eval in method scope doesn't define methods 839 2006-02-11 23:40 ┗[ko1 atdot.net ] fixed> Re: open> class_eval in method scope doesn't define methods 840 2006-02-12 00:55 ┣[matz ruby-lang.org ] 845 2006-02-12 16:00 ┗[sheepman sheepman.sa] close> class_eval in method scope doesn't define methods