摘要: 1.ruby定义函数与执行函数案例def fact(n) if n == 0 1 else n * fact(n-1) end endprint fact(4)结果: 242.一个小例子words = ['a','b','c'] secret = words[rand(3)] print "guess?\n" while guess = STDIN.gets guess.chop! if guess==secret print "You win!\n" break else print "Sorr 阅读全文
posted @ 2014-01-12 23:08 TBHacker 阅读(387) 评论(0) 推荐(0) 编辑