• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

Rubyを使い初めてから結構たちますが、まだ新しい発見というのはあるものですね。

class_evalでブロックを渡す時に、引数も渡したいと思っていたのですが、 class_execはちょうどその目的に使えるようです。

   1  FOO = lambda{|bar| puts bar}
   2  
   3  class Foo
   4    class_exec("Foo", &FOO)
   5  end #=> Foo

posted by Png genki on Sat 6 Aug 2011 at 19:28

Comments:

or Preview
Social Bookmarks
  • Delicious
  • B_entry1975
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ