Ruby ã§ããã¯ã¹ã¿ãã¯ãªã¼ãã¼ããã¼ãã¾ãã def add(n, a = 0) return a if n.zero? add(n - 1, n + a) end puts add(10000) #=>a.rb:2:in `add': stack level too deep (SystemStackError) ä¾ãã°ãã対çãã¾ãã obelisk.hatenablog.com ä¸ã®ã¨ãã以åã« Ruby ã§æ«å°¾å帰ã®ã¹ã¿ãã¯ãªã¼ãã¼ããã¼ãé¿ããæ¹æ³ãæ¸ããã®ã§ããããã¢ã³ãã¼ã¹ã¿ã³ãã£ã³ã° ã³ã³ãã¥ãã¼ã·ã§ã³ âåç´ãªæ©æ¢°ããä¸å¯è½ãªããã°ã©ã ã¾ã§ããèªãã§ããããRuby ã¯æ«å°¾å¼ã³åºãæé©åï¼Tail Call Optimizationï¼ããµãã¼ããã¦ããã¨ã®é©ãã¹ãè¨äºããã£ãï¼p.45 ï¼ããã®ããã°è¨äºã«ãæ¸ããã¦ããããããªæãã§ããã°ããããã ã tco = <
{{#tags}}- {{label}}
{{/tags}}