你能幫助的人我改變/邏輯組織log
項Ruby-訪問元素多維數組
input_array = [
["2/6/2014", "13:31:12", "IN", "application1", "user1", "machine1"]
["2/6/2014", "13:31:12", "IN", "application2", "user2", "machine2"]
["2/6/2014", "13:31:52", "IN", "application3", "user3", "machine3"]
["2/6/2014", "13:38:37", "OUT", "application1", "user1", "machine1"]
["2/6/2014", "14:46:37", "OUT", "application2", "user2", "machine2"]
["2/6/2014", "15:56:37", "OUT", "application3", "user3", "machine3"]
]
如何這個陣列中訪問單個元素..如2/6/2014
或application1
?
當我做input_array[1][4]
,所需的輸出是...
"application1" # and not 6 ... its giving me the 4 character in line 1
感謝您的幫助!
'線'是什麼?用這個間距,你的代碼是無效的。 – sawa
即使你使那個特定的語法有效,你仍然會得到一個字符串而不是一個數組。 –