14
|
1 lions
|
|
2 tigers
|
|
3 bears
|
|
4 Accessing undefined indexes gives nil
|
|
5 Negative indexes also work (like Python): -1 = bears
|
|
6 And you get slices/ranges: 1..2 = ["tigers", "bears"]
|
|
7 1..2 is even an object: Range
|
|
8 and indexers are methods: [1].methods.include?(:[]) = true
|
|
9 as is assignment to an array! [1].methods.include?(:[]=) = true
|
|
10
|
|
11 All funky non-ASCII methods for arrays:
|
|
12 ==
|
|
13 []
|
|
14 []=
|
|
15 <<
|
|
16 <=>
|
|
17 +
|
|
18 *
|
|
19 -
|
|
20 &
|
|
21 |
|
|
22 ===
|
|
23 =~
|
|
24 !~
|
|
25 !
|
|
26 !=
|
|
27
|
|
28 Arrays are also stacks with push() and pop() methods!
|