Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > dl/importライブラリ > DL::Functionクラス > bind

instance method DL::Function#bind

bind {|*args| ... }

自身に指定されたブロックをバインドします。 自身に対して call メソッドが呼ばれたとき、生成時に与えられた DL::CFunc オブジェクトではなく このブロックが呼ばれます。

例:

require 'dl/import'

cfunc = DL::CFunc.new(0, DL::TYPE_INT)
func  = DL::Function.new(cfunc, [DL::TYPE_INT])
func.bind{|i| i + 3  }
p func.call(2)             #=> 5
class DL::Function