Mercurial > repos > other > SevenLanguagesInSevenWeeks
changeset 28:25e66d77e1fe
Start the Day 1 excercises for Io and document the interactive stuff
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 05 Sep 2017 21:00:21 +0100 |
parents | 2ea3b5e9b41b |
children | 9c7af76fdbd0 |
files | 2-Io/day1.io |
diffstat | 1 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/2-Io/day1.io Tue Sep 05 21:00:21 2017 +0100 @@ -0,0 +1,23 @@ +# Calling "functions" is sending a "message" (right) to an object (left) +# ↓ object ↓ message +"Hi ho, Io" print + +# Object creation is by cloning and modifying root "Object" object +# Convention appears to be that classes start with capitals +Vehicle := Object clone + +# ":=" creates a "slot" (which can be a value or a function?), whereas "=" assigns to existing ones +Vehicle description := "A description of our vehicle" +# So this would fail because the slot doesn't exist - we'll repeat it at the end to stop it crashing our program too early! +# Vehicle another_field = "This won't work" + +# Fetching values is just calling the function (but we need an extra "print" to print to stdout) +Vehicle description print + +# In addition to the slot we created, there is a default slot called "type" +# (and presumably some default messages, because slotNames apparently isn't a slot!) +Vehicle slotNames print +Vehicle type print +Object type print + +Vehicle another_field = "This won't work" \ No newline at end of file