文章会有【原创】或者【转载】标示,部分来自Google Baidu的学习结果 {Java/PHP/Python/Ruby/Go}

Python列表/元祖/词典学习区分,Ruby数组和哈希【原创】  



a = ['aa',12,34,'phper.yang','578']
for i in a:
   print i

print "\r\n"

b = ('phper.yang','rubyer.yang','pythoner.yang')
print b[0]

print "\r\n"

c = {'php':'phper.yang','ruby':'rubyer'}
for key in c:
   print key,c[key]

我按照php的理解哈:
列表:我觉的就是不带key的数组 索引数组
元祖:一个用分隔符区分的字符串
词典:带key的数组 关联数组

ruby 操作数组和哈希的方法

a = ['php','ruby','python']
for lang in a
   puts lang
end

#####
哈希的两种写法。数组啦就是
#####
aa ={:one => "php",:two => "ruby",:three => "python"}
for k,v in aa
   puts "#{k} => #{v}"
end

aa.each do |k, v|
   puts "#{k} => #{v}"
end