2008年1月31日木曜日

ブロック引数の共用は有害である

 引数が既存のローカル変数の場合でその引数がブロックの引数として使われる場合、ブロック内部と外部で共用されることでの 予期せぬ事態は うまくない
 性能UPのためらしいが 
Parameters to a block may be existing local variables; if so, the new value of the variable will be retained after the block completes. This may lead to unexpected behavior, but there is also a performance gain to be had by using variables that already exist. For more information on this and other “gotchas,” see the section “But It Doesn't Work!”; more performance information can be found in the section “But It's Too Slow!”.

 

0 件のコメント: