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.
Rubyでコンマで区切られた引数を解析するにはどうすればよいですか?
例えば:
$> Main.rb --xmlid 1,2,3,4,5
1,2,3,4,5 を解析して配列に格納したいと考えています。
どうやってやるの?
ありがとう。
ARGVリストのインデックス (この場合は 1)がわかったら、次を使用します。
ARGV
ARGV[index].split(',') #=> ["1", "2", "3", "4", "5"]