博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Io Language Demo code first day
阅读量:6876 次
发布时间:2019-06-26

本文共 2879 字,大约阅读时间需要 9 分钟。

首字母大写为原型类,小写为对象

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"

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
==> 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

转载于:https://www.cnblogs.com/Brent-Chen/p/4898573.html

你可能感兴趣的文章
How Do Annotations Work in Java?--转
查看>>
查看centos中的用户和用户组
查看>>
web.xml中常用元素的解读
查看>>
Direct-X学习笔记--纹理映射
查看>>
使用接口实现多继承
查看>>
Foreach循环输出索引值
查看>>
041 SparkSql的回顾与复习
查看>>
myql基准测试工具Sysbench
查看>>
想拥有一款钢铁侠Jarvis管家的软件吗?
查看>>
web前端自动化测试利器puppeteer介绍
查看>>
Mac怎么生成.ssh文件
查看>>
“C语言” 读书札记(四)之[再续编译执行]
查看>>
[CODE] Dahua Lin贡献的两个开源软件
查看>>
高斯消元法求解线性方程组的解集
查看>>
C++ 沉思录——Chap5:代理类
查看>>
通向架构师的道路(第一天)之Apache整合Tomcat - lifetragedy的专栏 - 博客频道 - CSDN.NET...
查看>>
VS2015 android 设计器不能可视化问题解决。
查看>>
httppp 1.4.0 发布,HTTP响应时间监控
查看>>
52. N-Queens II
查看>>
【Mongodb】3.X 配置身份验证
查看>>