Skip to content

Instantly share code, notes, and snippets.

@connor
Created June 23, 2011 04:29
Show Gist options
  • Save connor/1041904 to your computer and use it in GitHub Desktop.
Save connor/1041904 to your computer and use it in GitHub Desktop.
Ruby array example
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
@connor
Copy link
Author

connor commented Jun 23, 2011

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment