[前][次][番号順一覧][スレッド一覧][生データ]

yarv-dev:751

From: sheepman <sheepman sheepman.sakura.ne.jp>
Date: Thu, 29 Dec 2005 09:33:24 +0900
Subject: [yarv-dev:751] open> self in a block given to send(:instance_eval)

こんにちは、sheepman です。
send 経由で instance_eval を呼ぶと、
ブロックの中での self が ruby-1.9 と違ってしまいます。

$ cat t.rb
Object.send(:instance_eval) do
  p self
end

$ ./miniruby -v t.rb
ruby 1.9.0 (2005-11-18) [i686-linux]
YARVCore 0.3.3 (rev: 339) [opts: ]
main

$ ruby-1.9 -v t.rb
ruby 1.9.0 (2005-12-28) [i686-linux]
Object

send 経由で class_eval を呼んでも同様です。

$ cat t.rb
Object.send(:class_eval) do
  p self
end

$ ./miniruby -v t.rb
ruby 1.9.0 (2005-11-18) [i686-linux]
YARVCore 0.3.3 (rev: 339) [opts: ]
main

$ ruby-1.9 -v t.rb
ruby 1.9.0 (2005-12-28) [i686-linux]
Object

-- 
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

[前][次][番号順一覧][スレッド一覧][生データ]

->     751 2005-12-29 09:33 [sheepman sheepman.sa] open> self in a block given to send(:instance_eval)
       753 2005-12-29 11:25 ┗[ko1 atdot.net       ] fixed> Re: open> self in a block given to send(:instance_eval)
       757 2005-12-30 20:55  ┗[sheepman sheepman.sa] close> self in a block given to send(:instance_eval)