Skip to content

Instantly share code, notes, and snippets.

@pointcom
Last active January 24, 2018 10:22
Show Gist options
  • Save pointcom/f407603ecabf42437026fb8d417c87bc to your computer and use it in GitHub Desktop.
Save pointcom/f407603ecabf42437026fb8d417c87bc to your computer and use it in GitHub Desktop.
# 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