Skip to content

Instantly share code, notes, and snippets.

@jgarber
Created November 13, 2013 16:50
Show Gist options
  • Select an option

  • Save jgarber/7452338 to your computer and use it in GitHub Desktop.

Select an option

Save jgarber/7452338 to your computer and use it in GitHub Desktop.
One of my students just asked about the behavior below and I didn't have a good answer. Do you have an explanation?
2.0.0p247 :001 > a = [1, 2]
=> [1, 2]
2.0.0p247 :002 > a[1]
=> 2
2.0.0p247 :003 > a[2]
=> nil
2.0.0p247 :004 > a[1,1]
=> [2]
2.0.0p247 :005 > a[2,1]
=> [] ## <- Why is this not nil?
2.0.0p247 :006 > a[3,1]
=> nil
@konata
Copy link
Copy Markdown

konata commented Nov 13, 2013

@jgarber
Copy link
Copy Markdown
Author

jgarber commented Nov 13, 2013

Yes, but that's all it says. Did you see an explanation?

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