ruby怎么实现数组减法
发布网友
发布时间:2022-07-07 01:04
我来回答
共1个回答
热心网友
时间:2022-07-15 08:22
数组的创建和初始化
a = Array.[](1,2,3,4)
b = Array[1,2,3,4]
c = [1,2,3,4]
d = Array.new #创建一个空数组
e = Array.new(3) #[nil,nil,nil] 初始大小3
f = Array.new(3,"xx") #["xx","xx","xx"] 初始大小3 初始值"xx"
f[0].capitalize! #=> ["Xx","Xx","Xx"]
g = Array.new(3){"yy"} #=> ["yy","yy","yy"]
g[0].capitalize! #=>["Yy","yy","yy"]