Io 20110905
Io> "HI" println
HI
==> HI
Io> Vehicle := Object clone
==> Vehicle_0x2458300:
type = "Vehicle"
Io> Vehicle description := "someting to take you places"
==> someting to take you places
Io> Vehicle description
==> someting to take you places
Io> Vehicle slotNames
==> list(description, type)
Io> Vehicle type
==> Vehicle
Io> Object type
==> Object
Io> Car := Vehicle clone
==> Car_0x222e560:
type = "Car"
Io> Car slotNames
==> list(type)
Io> Car type
==> Car
Io> Car Description
Exception: Car does not respond to ‘Description‘
---------
Car Description Command Line 1
Io> Car description
==> someting to take you places
Io> ferrari := Car clone
==> Car_0x234bb88:
Io> ferrari slotNames
==> list()
Io> ferrari type
==> Car
Io> method("So, you‘ve come for an argument." println)
==> method(
"So, you‘ve come for an argument." println
)
Io> method type
==> Block
Io> Car drive := method("Vroom" println)
==> method(
"Vroom" println
)
Io> ferrari drive
Vroom
==> Vroom
Io> ferrari proto
==> Car_0x222e560:
drive = method(...)
type = "Car"
Io> Lobby
==> Object_0x2176878:
Car = Car_0x222e560
Lobby = Object_0x2176878
Protos = Object_0x2176818
Vehicle = Vehicle_0x2458300
_ = Object_0x2176878
exit = method(...)
ferrari = Car_0x234bb88
forward = method(...)
set_ = method(...)
Io> toDos := list("find my car","find Continuum Transfunctioner")
==> list(find my car, find Continuum Transfunctioner)
Io> toDos size
==> 2
Io> toDos append("Find a present")
==> list(find my car, find Continuum Transfunctioner, Find a present)
Io> demoList := list(1,2,3,4)
==> list(1, 2, 3, 4)
Io> demoList average
==> 2.5
Io> demoList sum
==> 10
Io> demoList at(1)
==> 2
Io> demoList append(4)
==> list(1, 2, 3, 4, 4)
Io> demoList prepend(0)
==> list(0, 1, 2, 3, 4, 4)
Io> demoList isEmpty
==> false
Io> elvis := Map clone
==> Map_0x21dd5c8:
Io> elvis atPut("home","Graceland")
==> Map_0x21dd5c8:
Io> elvis at("home")
==> Graceland
Io> elvis atPut("style","rock and roll")
==> Map_0x21dd5c8:
Io> elvis asObject
==> Object_0x24df5a0:
home = "Graceland"
style = "rock and roll"
Io> elvis asList
==> list(list(home, Graceland), list(style, rock and roll))
Io> elvis keys
==> list(home, style)
Io> elvis size
==> 2
Io> true clone
==> true
Io> false clone
==> false
Io> nil clone
==> nil
Io> Highlander := Object clone
==> Highlander_0x24e92f0:
type = "Highlander"
Io> Highlander clone := Highlander
==> Highlander_0x24e92f0:
clone = Highlander_0x24e92f0
type = "Highlander"
Io> Highlander clone
==> Highlander_0x24e92f0:
clone = Highlander_0x24e92f0
type = "Highlander"
Io> fred := Highlander clone
==> Highlander_0x24e92f0:
clone = Highlander_0x24e92f0
type = "Highlander"
Io> mike :=Highlander clone
==> Highlander_0x24e92f0:
clone = Highlander_0x24e92f0
type = "Highlander"
Io> fred == mike
==> true
Io Language Demo code first day
原文:http://www.cnblogs.com/Brent-Chen/p/4898573.html