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

毎度忘れるRubyの配列操作

More than 3 years have passed since last update.

毎度ggっているので備忘録。versionは2.2.2

やりたいこと メソッド
末尾から取り出す pop
末尾に追加する push
先頭から取り出す shift
先頭に挿入する unshift
irb(main):001:0> array = [1, 2, 3, 4, 5]
=> [1, 2, 3, 4, 5]
irb(main):002:0> array.pop
=> 5
irb(main):003:0> array
=> [1, 2, 3, 4]
irb(main):004:0> array.push(5)
=> [1, 2, 3, 4, 5]
irb(main):005:0> array.shift
=> 1
irb(main):006:0> array
=> [2, 3, 4, 5]
irb(main):007:0> array.unshift(1)
=> [1, 2, 3, 4, 5]
irb(main):008:0>

どれも破壊的ですね。

Why do not you register as a user and use Qiita more conveniently?
  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
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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