Last active
January 24, 2018 10:22
-
-
Save pointcom/f407603ecabf42437026fb8d417c87bc to your computer and use it in GitHub Desktop.
This file contains 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
# You can create an array of one string element with * | |
my_array = *"hello" | |
=> ["hello"] | |
arr = %w(a b c) | |
=> ["a", "b", "c"] | |
head, *tail = arr | |
=> ["a", "b", "c"] | |
head | |
=> "a" | |
tail | |
=> ["b", "c"] | |
first, *, last = arr | |
=> ["a", "b", "c"] | |
first | |
=> "a" | |
last | |
=> "c" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment