如何利用ruby去除数组最后两个数据
展开全部
数组的创建和初始化
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"]
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"]
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询