RFS: Arrays - 005

Arrays are list of things. That's the easiest way to think about it. Arrays are used widely in web development. In this episode we'll explore some basic usage of Arrays.

Array Examples

We can create an empty array like so.

list = []

We can add things into this array

list += ["Zack"]=> ["Zack"]list += [2]=> ["Zack", 2]list += ["Savika"]=> ["Zack", 2, "Savika"]list += [3]=> ["Zack", 2, "Savika", 3]list += ["Phavit", 1]=> ["Zack", 2, "Savika", 3, "Phavit", 1]

We can now loop out the items in this list

list.each do |n|  puts nend

We can do many more things with arrays these are just some basic examples. Try out some examples from the documentation!