O'Reilly logo

Learn Ruby the Hard Way: A Simple and Idiomatic Introduction to the Imaginative World of Computational Thinking with Code, Third Edition, Video Enhanced Edition by Zed A. Shaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exercise 38. Doing Things to Arrays

Image

You have learned about arrays. When you learned about while-loops you “appended” numbers to the end of an array and printed them out. There were also Study Drills where you were supposed to find all the other things you can do to arrays in the Ruby documentation. That was a while back, so review those topics if you do not know what I’m talking about.

Found it? Remember it? Good. When you did this you had an array, and you “called” the function push on it. However, you may not really understand what’s going on so let’s see what we can do to arrays.

When you write mystuff.push('hello'), you are actually setting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required