2015-06-16から1日間の記事一覧

RubyやRailsでメソッドを上書き・処理追加する方法いろいろ

オープンクラス class Hoge def hello 'HELLO' end end class Hoge def hello 'hello taro!' end end p Hoge.new.hello #=> "hello taro!" aliasでいったんメソッド名を退避するテクニック class Hoge def hello 'HELLO' end end class Hoge # (3) hello2の…