# HG changeset patch # User IBBoard # Date 1504719764 -3600 # Node ID d43f60e98f39eb4c36ead4d17fc236d799c2a49e # Parent 9c7af76fdbd0dde7ceb14c21197e8ec277e39a40 Complete the car example of objects and types diff -r 9c7af76fdbd0 -r d43f60e98f39 2-Io/day1.io --- a/2-Io/day1.io Wed Sep 06 18:36:02 2017 +0100 +++ b/2-Io/day1.io Wed Sep 06 18:42:44 2017 +0100 @@ -25,4 +25,38 @@ Object type print "\n" print +# Now we start making a Ferrari as a type of car +Car := Vehicle clone +# Car only directly has one slot +# (Q: How do we find out inhereted slots?) +Car slotNames print +"\n" print +Car type print +"\n" print +# But because of prototype cloning, the description remains the same +Car description print +"\n" print + +# Now we make a specifc car +ferrari := Car clone +# But this hasn't gained any slots because it is lower-case +ferrari slotNames print +"\n" print +# It does still have a type, though +ferrari type print +"\n" print + +# Types don't mean anything specific - they're just a handy convention +# Variables are case sensitive, so we can make an entire type of Ferraris +Ferrari := Car clone +Ferrari type print +"\n" print +Ferrari slotNames print +"\n" print +# And the lower-case version is unaffected +ferrari slotNames print +"\n" print + + + Vehicle another_field = "This won't work" \ No newline at end of file