Skip to content

Instantly share code, notes, and snippets.

@IanWhitney
Created November 18, 2015 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanWhitney/4c98529556e455dd84e2 to your computer and use it in GitHub Desktop.
Save IanWhitney/4c98529556e455dd84e2 to your computer and use it in GitHub Desktop.
[1,2,3][3]
#=> nil
# Ask for element outside of the array, get nil. cool.
[1,2,3][3,1]
#=> []
#=> Ask for a 1-element slice that starts outside of the array, get an empty array. Ok?
[1,2,3][4]
#=> nil
# Ask for element 2 spots outside of the array, get nil. Ok, so the slice behavior should be the same.
[1,2,3][4,1]
#=> nil
#=> Nope!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment