Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Foundations Blocks Examples

Why so you add a number *= 2 line in the block and not explain why it didn't change the array? thanks

The example of block shows array with 5 numbers, in the number block you add a number *2 line which doesn't seem to apply to any part of the array, yet there's no explanation about why the line was added...

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

The line was added to show you that it does not influence the original array and to show that if you apply that change AFTER printing, you will not se that change, because it's temporary and local. You should experiment with this code on your own to understand what is going on. For example add the puts line after the *= 2 line and see what happens.