Rubyã®ããã©ã«ãå¼æ°ã§ã¯ãä»ã®å¼æ°ã«ä¾åããå¼ãæ¸ãããå°å³ã«ä¾¿å©ã [1] pry(main)> def foo(a, b = a * 2) [1] pry(main)* puts b [1] pry(main)* end => nil [2] pry(main)> foo(3) 6 => nil å帰ãããããããã©ã«ãå¼æ°ã§å帰ããã¦ãã£ããã£ã¦ã¿ã [3] pry(main)> def fib(n,r = (n <=1 ? n : fib(n-2) + fib(n-1))) [3] pry(main)* r [3] pry(main)* end => nil [4] pry(main)> 11.times do |n| puts "fib(#{n}) => #{fib(n)}" end fib(0) => 0 fib(1) => 1 fib(2) => 1 fib(3) =>
{{#tags}}- {{label}}
{{/tags}}