require 'pp' p *1..10
This prints out 1-10. Why is this so concise? And what else can you do with it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is ‘the splat’ operator. It can be used to explode arrays and ranges and collect values during assignment.
Here the values in an assignment are collected:
In this example the values in the inner array (the
[3,4]one) is exploded and collected to the containing array:You can define functions that collect arguments into an array: