LoginSignup
14
14

More than 5 years have passed since last update.

空の2次元配列初期化

Last updated at Posted at 2014-10-17

objのサイズの数の空配列を持った2次元配列を生成する

Array.new(obj.size).map{[]}

10/20 追記

@riocampos さんからよりシンプルな書き方を指摘いただきました。
ありがとうございます!

Array.new(obj.size) { [] }
14
14
3

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
14
14