There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
We have essentially defined an object which can be iterated. The memory footprint is very small since we don’t preserve the data structure if it is never assigned.
How big will be the footprint of,
puts array_of_10.map {|x| x * 2}
?
Answer? 0.
There is nothing stored in memory.
We soon learn to make great use of this methodology in Ruby since it is largely, or wholly based upon methods.
Upon resetting and immediately running the provided code, nothing appears in the console. There is only one puts, which is written in the method.
The correction for this is to remove the puts from the method and print the method, which still amounts to one puts. We’ve covered this above. Study that answer if you don’t understand it. Due diligence would involve Ruby docs.
As for the 40, I’m still out in woods on that one.
So if I am understanding correctly, having the puts written in the method does not actually print on the console. That is why we have to remove it from the method that the program provided and call it in a different line. Is that correct?