ããã«ã¡ã¯ããã¾ããã§ãã æè¿ã®JavaScript人æ°ã«ä¾¿ä¹ãã¦ããã®ç¹å¾´ã§ããã¯ãã¼ã¸ã£ãRubyã§ã使ã£ã¦ã¿ããã¨ãããã¾ãã ã¾ãã¯ãããããªJavaScriptã«ããã¯ãã¼ã¸ã£ã®ä¾ã§ãã var f = (function f() { var i = 0; return function() { console.log(i++); } })(); f() // => 0 f() // => 1 f() // => 2 f() // => 3 ãããRubyã§æ¸ãã¦ã¿ãã¨ãããªãã¾ãã def f i = 0 Proc.new { puts i; i += 1 } end _f = f _f.call # => 0 _f.call # => 1 _f.call # => 2 _f.call # => 3 ããããã®éããè¦ã¦ããã¾ãããã ã¾ãJavaScriptãå¤æ° f ã«ç
{{#tags}}- {{label}}
{{/tags}}