What does .map do in:
params = (0...param_count).map
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.
The
mapmethod takes an enumerable object and a block, and runs the block for each element, outputting each returned value from the block (the original object is unchanged unless you usemap!):ArrayandRangeare enumerable types.mapwith a block returns an Array.map!mutates the original array.Where is this helpful, and what is the difference between
map!andeach? Here is an example:The output: