annotate 1-Ruby/arrays-ruby.output @ 29:9c7af76fdbd0

Print isn't PrinLn, so add some \n characters to the output
author IBBoard <dev@ibboard.co.uk>
date Wed, 06 Sep 2017 18:36:02 +0100
parents 9aa1eba404f0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 lions
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 tigers
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 bears
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 Accessing undefined indexes gives nil
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 Negative indexes also work (like Python): -1 = bears
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 And you get slices/ranges: 1..2 = ["tigers", "bears"]
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 1..2 is even an object: Range
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 and indexers are methods: [1].methods.include?(:[]) = true
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 as is assignment to an array! [1].methods.include?(:[]=) = true
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 All funky non-ASCII methods for arrays:
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 ==
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 []
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 []=
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 <<
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 <=>
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 +
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 *
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 -
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 &
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 |
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 ===
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 =~
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 !~
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 !
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 !=
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27
9aa1eba404f0 Add some poking of arrays
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 Arrays are also stacks with push() and pop() methods!