# HG changeset patch # User IBBoard # Date 1505243224 -3600 # Node ID 15eb99e79dd4a7b3a7cb509ead61797e1046f8b2 # Parent 22edfbf3b8bde14e4f360b72ae51ecbfc9c01f1e Call methods by name and fix slot name printing diff -r 22edfbf3b8bd -r 15eb99e79dd4 2-Io/day1-self-study.io --- 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