Ruby 基础教程1-7

后端开发   发布日期:2025年07月16日   浏览次数:120

函数:

  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)

以上就是Ruby 基础教程1-7的详细内容,更多关于Ruby 基础教程1-7的资料请关注九品源码其它相关文章!