2011-06-01から1ヶ月間の記事一覧

トップレベルでのメソッド定義とSimpleDelegator

たまたまRuby 1.9.2でportupgradeを動かした時に気付いたのですが、以下のコードがRuby 1.8.7とRuby 1.9.2とで挙動が異なります。 require 'delegate' def foo :foo end class A < SimpleDelegator def initialize @obj = [] super(@obj) end def bar foo en…