Ruby Scripting - Array

A literal array is created by putting square
brackets around a comma-separated list of elements

eg:

# ["zero" , "un" , "dos" , "tre" ]
a = ['zero' , 'un' , 'dos' , 'tre' ]


# 4
a.length

# 4
a.size

# "zero"
a[0]


# ["un" , "dos" , "tre" ]
a[1..3]

 

posted @ 2014-02-20 17:35  Master HaKu  阅读(235)  评论(0编辑  收藏  举报