返回顶部

收藏

Replace one array with another

更多
#!/usr/bin/env ruby

i = 0
breeds = [ 'quarter', 'arabian', 'appalosa', 'paint' ]
puts breeds.size # => 4
temp = []

while i < breeds.size do
  temp << breeds[i].capitalize
  i += 1
end

temp.sort! # => ['Appalosa', 'Arabian', 'Paint', 'Quarter']
breeds.replace( temp )
p breeds # => ['Appalosa', 'Arabian', 'Paint', 'Quarter']

标签:Ruby,Statement

收藏

0人收藏

支持

0

反对

0

发表评论