"Run the module `demo`."
shared void run() {
支持 span 换行
//print("hello world");
//
//print("hello
// world");
//normalized String 规范化
//String message = "hello
// normalized";
//print(message.normalized);
// String 报错 因为 String name 没有 process.arguments.first
//String name = process.arguments.first; //compile error: String? is not assignable to String
//String greeting = "Hello, ``name``!";
//print(greeting);
防止 name 没有找到 报 空指针异常
//String? name = process.arguments.first;
//String greeting;
//if (exists name) {
// greeting = "Hello, ``name``!";
//}
//else {
// greeting = "Hello, World!";
//}
//print(greeting);
//Counter counter = Counter(10.0,5.0);
//Counter a = counter.rotate(2.0);
//print(a.description);
//Counter counter = Counter(30.0,60.0,null);
//print(counter.procs);
//print(counter.description);
//print(counter.inc());
// get set 使用
// 方式一
//counter.name="cdcd";
//print(counter.name);
方式 2
//counter.setNickNamen("finn");
//print(counter.getNickName());
//继承
LabeledPolar labelPolar = LabeledPolar(10.0,12.0,"labletest");
// 方法 重写
print(labelPolar.description);
// 流
//{String+} words = { "hello", "world" };
//{String+} moreWords = { "hola", "mundo",*words};
//print(words);
//print(moreWords);
迭代
//for (word in moreWords) {
// print(word);
//}
索引 i
//for (i -> word in moreWords.indexed) {
// print("``i``: ``word``");
//}
variable value counter = 0;
value stream = { for (i in 0:5) counter++ }; //curly braces means LAZY!
print(stream); //evaluate elements
print(stream); //reevaluate elements
//print(counter);
// 数组使用
// String[] names =["cdd","finn","amy"];
// for(name in names)
// {
// print("hello"+ name);
// }
}
//注解方式1
shared void hello() {
print("Hello, World!");
}
/* The classic Hello World program */
shared void hello2() {
print("Hello, World!");
}
ceylon 学习 3 代码片段
最新推荐文章于 2021-02-20 20:12:16 发布