forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 2
Ruby Arrays
Quincy Larson edited this page Aug 20, 2016
·
1 revision
- Arrays are a list of indexed items stored inside
[]
brackets. - Ruby uses zero-based indexing. This means the first item in the array is stored in index number
0
, then the second is at index number1
, and so on incrementing by values of 1 for each additional item stored in the array. - Arrays can be created using
[]
orArray.new
syntax. - Ruby has many build in methods to perform operations on arrays such as reversing or finding an element stored in the array.
arr = [1,2,3]
# is equivalent to:
arr = Array.new(3)
arr[0] = 1
arr[1] = 2
arr[2] = 3
# is also equivalent to:
arr = Array(1..3)
# All three of these examples return:
[1,2,3]
Previous | Home | Next |
---|---|---|
Ruby Numbers | Table of Contents | Ruby Hashes |
Learn to code and help nonprofits. Join our open source community in 15 seconds at http://freecodecamp.com
Follow our Medium blog
Follow Quincy on Quora
Follow us on Twitter
Like us on Facebook
And be sure to click the "Star" button in the upper right of this page.
New to Free Code Camp?
JS Concepts
JS Language Reference
- arguments
- Array.prototype.filter
- Array.prototype.indexOf
- Array.prototype.map
- Array.prototype.pop
- Array.prototype.push
- Array.prototype.shift
- Array.prototype.slice
- Array.prototype.some
- Array.prototype.toString
- Boolean
- for loop
- for..in loop
- for..of loop
- String.prototype.split
- String.prototype.toLowerCase
- String.prototype.toUpperCase
- undefined
Other Links