LoginSignup
2
0

More than 5 years have passed since last update.

スペース区切りの文字列をsplitして整数の配列にしたい

Last updated at Posted at 2018-02-21

問題を解いていて調べたのでメモ

"1 2 3 4 5".split(" ").map(&:to_i)
=> [1, 2, 3, 4, 5]

理解が正しければ下と同じこと

"1 2 3 4 5".split(" ").map { |num|
  num.to_i
}
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0