首字母大写为原型类,小写为对象
Io 20110905
Io> "HI" printlnHI==> HIIo> Vehicle := Object clone==> Vehicle_0x2458300: type = "Vehicle"Io> Vehicle description := "someting to take you places"
==> someting to take you placesIo> Vehicle description==> someting to take you placesIo> Vehicle slotNames==> list(description, type)Io> Vehicle type==> VehicleIo> Object type==> ObjectIo> Car := Vehicle clone==> Car_0x222e560: type = "Car"Io> Car slotNames
==> list(type)Io> Car type==> CarIo> Car DescriptionException: Car does not respond to 'Description'
--------- Car Description Command Line 1Io> Car description
==> someting to take you placesIo> 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==> BlockIo> Car drive := method("Vroom" println)
==> method( "Vroom" println)Io> ferrari driveVroom==> VroomIo> ferrari proto
==> Car_0x222e560: drive = method(...) type = "Car"Lobby
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(...)列表list和映射map
Io> toDos := list("find my car","find Continuum Transfunctioner")
==> list(find my car, find Continuum Transfunctioner)Io> toDos size==> 2Io> 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.5Io> demoList sum==> 10Io> demoList at(1)==> 2Io> demoList append(4)==> list(1, 2, 3, 4, 4)Io> demoList prepend(0)
==> list(0, 1, 2, 3, 4, 4)Io> demoList isEmpty
==> falseIo> elvis := Map clone
==> Map_0x21dd5c8:Io> elvis atPut("home","Graceland")
==> Map_0x21dd5c8:Io> elvis at("home")
==> GracelandIo> 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
==> trueIo> false clone==> falseIo> nil clone==> nilIo> 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