Skip to content

Instantly share code, notes, and snippets.

@chrishunt
Created February 22, 2012 17:46
Show Gist options
  • Save chrishunt/1886281 to your computer and use it in GitHub Desktop.
Save chrishunt/1886281 to your computer and use it in GitHub Desktop.
Array.fetch
class Array
def [](index)
fetch(index)
end
end
> basket = ['bread', 'wine']
=> ["bread", "wine"]
> basket[2]
IndexError: index 2 outside of array bounds: -2...2
from (irb):14:in `fetch'
from (irb):14
from /Users/huntca/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment