ruby code example(7)

ruby code example(7)
##数组
a = [ 'ant', 'bee', 'cat', 'dog', 'elk' ]
a[0]
a[3]
# this is the same:
a = %w{ ant bee cat dog elk }
a[0]
a[3]

##hash表
inst_section = {
'cello' => 'string',
'clarinet' => 'woodwind',
'drum' => 'percussion',
'oboe' => 'woodwind',
'trumpet' => 'brass',
'violin' => 'string'
}

inst_section['oboe']
inst_section['cello']
inst_section['bassoon']

你可能感兴趣的:(ruby code example(7))