Container Creation

To initialize a container we will do the same steps showing code to support the things that have to be done. We create a table where we can add elements to the contents delete objects from either the beginning or the last entries and display an entry using the index or content on the index. We initialize/create the array with the following syntax:

class BookList
def initialize
@books = Array.new
end
end

We now have a table of book titles to which to add, delete and move data from. In the next post we will use the ‘append’ command to input data into the container we have just created.

This entry was posted in Development, Programming Basics and tagged , . Bookmark the permalink. Comments are closed, but you can leave a trackback: Trackback URL.