Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
test = Array.new test[0] = "foo"
正常に動作します
test[] = "foo"
エラーを返します。配列にインデックスを自動的に生成させるRuby構文は何ですか?
test << "foo"
また
test.push("foo").
この形式:
説明しているように、配列に要素を追加します。