Skip to content

Instantly share code, notes, and snippets.

@Qooh0
Created November 30, 2014 09:14
Show Gist options
  • Save Qooh0/0a3141e1203da9e3b59b to your computer and use it in GitHub Desktop.
Save Qooh0/0a3141e1203da9e3b59b to your computer and use it in GitHub Desktop.
Python と ruby のスライス memo ref: http://qiita.com/Qooh0@github/items/5cf2b3ea869716dcaf5a
irb(main):014:0> a = [1, 2, 3, 4, 5]
=> [1, 2, 3, 4, 5]
irb(main):024:0> a[0..3]
=> [1, 2, 3, 4]
irb(main):018:0> a[1..3]
=> [2, 3, 4]
In [3]: a
Out[3]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
In [4]: a[0:3]
Out[4]: [1, 2, 3]
In [5]: a[1:3]
Out[5]: [2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment