Skip to content

Instantly share code, notes, and snippets.

@YumaInaura
Last active July 6, 2017 03:29
Show Gist options
  • Select an option

  • Save YumaInaura/b873a696f24dda356cb8 to your computer and use it in GitHub Desktop.

Select an option

Save YumaInaura/b873a696f24dda356cb8 to your computer and use it in GitHub Desktop.
Ruby | 配列で最初の要素だけを削除する ( 2行目以降を全て得る ) ref: http://qiita.com/Yinaura/items/129f702553c5b6027bfb
['A','B','C','D','E'].drop(1)
# => ["B", "C", "D", "E"]
['A','B','C','D','E'].shift
=> "A"
['A','B','C','D','E'].shift!
# => NoMethodError: undefined method `shift!' for ["A", "B", "C", "D", "E"]:Array
alphabets = ['A','B','C','D','E']
alphabets.shift
alphabets
# => ["B", "C", "D", "E"]
['A','B','C','D','E'][1..-1]
# => ["B", "C", "D", "E"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment