ceylon 学习 3 代码片段
2016-05-31 14:08
288 查看
"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!"); }
相关文章推荐
- OC语言12-description方法和sel
- 0622 python 基础05
- python06-切片、列表生成器
- 0617 python 基础04
- 0610 python 基础03
- OC语言11-类的深入和分类
- java中过滤器的使用
- 用eclipse开发maven项目资源文件不编译问题
- MFC,halcon混合编程 遍历目录文件夹下的图像并显示在对话框上
- java基础
- OC语言10-构造方法
- Spring入门
- 什么时候应该避免写代码注释?
- python启动应用程序和终止应用程序
- python数据保存
- KMP算法及java实现
- 从0开始学习 GitHub 系列之「初识 GitHub」
- (Java)LeetCode-20. Valid Parentheses
- 模板与c++11--右值引用
- C++中placement new操作符(经典)