Skip to content

Instantly share code, notes, and snippets.

@rennex
Created August 15, 2014 02:54
Show Gist options
  • Save rennex/72634aecaba414e6e11a to your computer and use it in GitHub Desktop.
Save rennex/72634aecaba414e6e11a to your computer and use it in GitHub Desktop.
playing with the * prefix in ruby
[1] pry(main)> x = (1..5)
=> 1..5
[2] pry(main)> p x
1..5
=> 1..5
[3] pry(main)> p *x
1
2
3
4
5
=> [1, 2, 3, 4, 5]
[4] pry(main)> y=*x
=> [1, 2, 3, 4, 5]
[5] pry(main)> *x
SyntaxError: unexpected '\n', expecting '='
[5] pry(main)> *x=
[5] pry(main)* 123
=> 123
[6] pry(main)> x
=> [123]
[7] pry(main)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment