diff 1-Ruby/arrays-ruby.output @ 14:9aa1eba404f0

Add some poking of arrays
author IBBoard <dev@ibboard.co.uk>
date Tue, 03 Jan 2017 20:28:17 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/1-Ruby/arrays-ruby.output	Tue Jan 03 20:28:17 2017 +0000
@@ -0,0 +1,28 @@
+lions
+tigers
+bears
+Accessing undefined indexes gives nil
+Negative indexes also work (like Python): -1 =  bears
+And you get slices/ranges: 1..2 = ["tigers", "bears"]
+1..2 is even an object: Range
+and indexers are methods: [1].methods.include?(:[]) = true
+as is assignment to an array! [1].methods.include?(:[]=) = true
+
+All funky non-ASCII methods for arrays:
+==
+[]
+[]=
+<<
+<=>
++
+*
+-
+&
+|
+===
+=~
+!~
+!
+!=
+
+Arrays are also stacks with push() and pop() methods!