LoginSignup
3
3

More than 5 years have passed since last update.

Python と ruby のスライス memo

Posted at

Python と ruby を行ったり来たりすると、混乱するのでメモ

  • ruby

配列のインデックス番号

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]
  • python

ポインターの指す場所

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]
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3