Help us understand the problem. What is going on with this article?

rubyで処理をループで回して実行する簡潔な書き方 (Array#map編)

More than 3 years have passed since last update.

配列の中の文字列の文字数が知りたい…
という時は

array = ["hoge", "fuga", "piyo", "ihr"]
array.map do |row|
  row.length
end

このような処理がrubyでは

array = ["hoge", "fuga", "piyo", "ihr"]
array.map(&:length)

このように簡単に書けます。

mixi
全ての人に心地よいつながりを
http://mixi.co.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away