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でこれと同等のことを誤って行ってしまいました。
a = *1..5 # => [1, 2, 3, 4, 5] a << a a # => [1, 2, 3, 4, 5, [...]] a.last # => [1, 2, 3, 4, 5, [...]]
それとは何ですか、そして私は[...]それで何ができますか?
[...]
Array.inspect が再帰配列を表示する方法です。a の最後の要素はそれ自体です。5 の後に where が表示された場合、inspect は無限ループに陥ります。
[1, 2, 3, 4, 5, [1, 2, 3, 4, 5, [1, 2, 3, 4, 5, [1, 2, 3, 4, 5, [...]]]]]