ceylon 学习 3 代码片段

"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!");
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值