摘要: def do_n_times(n){ i = 1 while( i#{x}" }# --->1# --->2# --->3上面是使用关键字 yeild 来调用代码块,而下面的例子,在方法定义的时候定义了一个Proc 参数( 索引到传入的块),这个 Proc 参数需放在参数列表的最后,然后在方法里... 阅读全文
posted @ 2014-08-24 14:39 LaoQuans 阅读(319) 评论(0) 推荐(0) 编辑
摘要: def hello # A nice simple method puts "Hello World" # Suppose we want to augment it...end alias original_hello hello # Give the method a backup named... 阅读全文
posted @ 2014-08-24 10:07 LaoQuans 阅读(342) 评论(0) 推荐(0) 编辑