changeset 36:15eb99e79dd4

Call methods by name and fix slot name printing
author IBBoard <dev@ibboard.co.uk>
date Tue, 12 Sep 2017 20:07:04 +0100
parents 22edfbf3b8bd
children 86668d32e162
files 2-Io/day1-self-study.io
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/2-Io/day1-self-study.io	Wed Sep 06 19:54:35 2017 +0100
+++ b/2-Io/day1-self-study.io	Tue Sep 12 20:07:04 2017 +0100
@@ -37,7 +37,21 @@
 myvar2 type proto type println
 # Or, of course, a Prototype is a named object that starts with a capital letter
 # So we can just use slotNames to get them programmatically (but that only shows direct slots)
-SubClass slotNames println
+myvar slotNames println
+# And to get the parent ones then we just chain "proto"
+myvar proto slotNames println
+myvar proto proto slotNames println
+# If I knew enough Io then I'd do a recursion loop and walk up until proto == Object
+
+
+
+#Execute methods by slot name - use "perform"
+SubClass method1 := method("Method 1 was called" println)
+SubClass method2 := method("Method 2 was called" println)
+myvar2 perform("method1")
+myvar2 perform("method2")
+
+
 
 # Is Io strongly or weakly typed?
 (1 + 1) println