Last active
July 6, 2017 03:29
-
-
Save YumaInaura/b873a696f24dda356cb8 to your computer and use it in GitHub Desktop.
Ruby | 配列で最初の要素だけを削除する ( 2行目以降を全て得る ) ref: http://qiita.com/Yinaura/items/129f702553c5b6027bfb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ['A','B','C','D','E'].drop(1) | |
| # => ["B", "C", "D", "E"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ['A','B','C','D','E'].shift | |
| => "A" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ['A','B','C','D','E'].shift! | |
| # => NoMethodError: undefined method `shift!' for ["A", "B", "C", "D", "E"]:Array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alphabets = ['A','B','C','D','E'] | |
| alphabets.shift | |
| alphabets | |
| # => ["B", "C", "D", "E"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ['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