Ruby中数组的操作 2016-09-21 123456789101112131415161718192021222324# 创建并打印数组array = ['one', 'two', 'three']p array # => ["one", "two", "three"]p array[1] # => "two"# 增加数组元素# 我们可以这样的array << ["four"]p array # => ["one", "two", "three", "four"]# 还可以这样array.concat(["five"])p array # => ["one", "two", "three", "four", "five"]# 获取数组的数量p array.count # => 5# 获取数组特定元素的数量array << ["two"] # => ["one", "two", "three", "four", "five", "two"]p array("two").cout # => 2# 清空数组array.clearp array # => []