Ruby 基础教程1-7

函数:

  1. foo(x,y,z)
  2. foo(x,*args)
  3. foo(x,*args,c)
  4. foo(x=0,y="a")
  5. 2.0以后参数可以关键字指定 foo(x:0,y:0,z:0) 调用 foo(x:1,y:3,z:4)
 
def block_test
     yield 8,9
end

block_test {|t,m|puts t*m}

def cupt(*args)
     p args.class.name
end

para=[5,6,7]

puts cupt(2,3,4)
puts cupt(para)
原文地址:https://www.cnblogs.com/manziluo/p/5800153.html