LoginSignup
0
0

More than 3 years have passed since last update.

[Rails備忘録]配列を平坦化させる Array#flatten

Last updated at Posted at 2020-03-23

Railsの備忘録です。

Array#flatten

# 自身を再帰的に平坦化する例。
a = [1, [2, 3, [4], 5]]
p a.flatten                     #=> [1, 2, 3, 4, 5]
p a                             #=> [1, [2, 3, [4], 5]]

参考ページ

Ruby 2.7.0 リファレンスマニュアル instance method Array#flatten

[初心者向け] RubyやRailsでリファクタリングに使えそうなイディオムとか便利メソッドとか

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