Created
June 23, 2011 04:29
-
-
Save connor/1041904 to your computer and use it in GitHub Desktop.
Ruby array example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = [ :zero, :one, :two, :three, :four ] | |
print array.length # 5 | |
print :four == array[4] # true — zero-indexed, so array[4] is the 5th item. | |
print array[5].nil? # true | |
print array[6].nil? #true | |
print [] # nil | |
print array[5, 0] # nil | |
print [] == array[5, 0] # true b/c both are nil | |
print nil # nil | |
print array[6, 0] # nil | |
print bil == array[5, 0] # true b/c both are nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, that makes sense. Thanks for pointing that out! Sorry I wasn't more of a concrete answer, but I'm glad you found it!