comparison 2-Io/day1.io @ 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 25e66d77e1fe
children d43f60e98f39
comparison
equal deleted inserted replaced
28:25e66d77e1fe 29:9c7af76fdbd0
1 # Calling "functions" is sending a "message" (right) to an object (left) 1 # Calling "functions" is sending a "message" (right) to an object (left)
2 # ↓ object ↓ message 2 # ↓ object ↓ message
3 "Hi ho, Io" print 3 "Hi ho, Io\n" print
4 4
5 # Object creation is by cloning and modifying root "Object" object 5 # Object creation is by cloning and modifying root "Object" object
6 # Convention appears to be that classes start with capitals 6 # Convention appears to be that classes start with capitals
7 Vehicle := Object clone 7 Vehicle := Object clone
8 8
9 # ":=" creates a "slot" (which can be a value or a function?), whereas "=" assigns to existing ones 9 # ":=" creates a "slot" (which can be a value or a function?), whereas "=" assigns to existing ones
10 Vehicle description := "A description of our vehicle" 10 Vehicle description := "A description of our vehicle"
11 # 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! 11 # 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!
12 # Vehicle another_field = "This won't work" 12 # Vehicle another_field = "This won't work"
13 13
14 # Fetching values is just calling the function (but we need an extra "print" to print to stdout) 14 # Fetching values is just calling the function
15 # (but we need to skip ahead of what's in the book and chain an extra "print" to print to stdout)
15 Vehicle description print 16 Vehicle description print
17 "\n" print
16 18
17 # In addition to the slot we created, there is a default slot called "type" 19 # In addition to the slot we created, there is a default slot called "type"
18 # (and presumably some default messages, because slotNames apparently isn't a slot!) 20 # (and presumably some default messages, because slotNames apparently isn't a slot!)
19 Vehicle slotNames print 21 Vehicle slotNames print
22 "\n" print
20 Vehicle type print 23 Vehicle type print
24 "\n" print
21 Object type print 25 Object type print
26 "\n" print
22 27
23 Vehicle another_field = "This won't work" 28 Vehicle another_field = "This won't work"