Python, 備忘録 | 00:43 | __call__ メソッドは、オブジェクトが関数として呼び出された際に実行される特殊メソッドらしいので、その確認。 >>> class Test(object): ... def __init__(self): ... print "test01" ... def __call__(self): ... print "test02" >>> t01 = Test() test01 >>> t01() test02
In order to explain how the createDelegate function works in the last post, we have to understand JavaScript closures and Function.apply(). The apply() method is the easiest subject to tackle, so we'll start there and work up. Every function in JavaScript has a number of attached methods, including toString(), call(), and apply(). If it sounds odd to you that a function might have its own methods
342 名前:Name_Not_Found[] 投稿日:2007/10/10(水) 13:05:02 ID:0D5oBjKl callとapplyがよくわかりません。理解のためのヒントお願いします。 343 名前:Name_Not_Found[sage] 投稿日:2007/10/10(水) 13:57:44 ID:??? >>342 JavaScriptでは関数を変数に入れておくことができるよね。 var fn = function(s, t) { alert(s+t); }; fn('hello', 'world'); ←呼び出す しかしこの方法だとオブジェクトのメソッド呼び出しはできない var obj = new XXX(...); obj.fn1 = fn; obj.fn1('hello', 'world'); 上記のように書き換えてしまえばできるけど書き換えたくないことも。で、
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く