摘要:
1 #求阶乘方法一 2 def f1(n) 3 if n == 1 4 return 1 5 else 6 return n * f1(n-1) 7 end 8 end 9 10 #求阶乘方法二 11 def f2(n) 12 i = 1 13 while n > 0 14 i *= n 15 n -= 1 16 ... 阅读全文
摘要:
The 'require' method will not look in the current directory for files to load(but you can userequire './test.rb' to look in the current directory), bu... 阅读全文
摘要:
map and collect are the same, theyreturn an array constructed as the result of calling the block for each item in the array.irb(main):002:0> [1,2,3,4]... 阅读全文