ceylon--say more,more clearly ---(1) Basics



Let's get started!

让我们开始吧!

Before we can get into any of the really interesting and powerful features of this language, we need to get comfortable with some of the basic syntax, so we'll know what we're looking at later on, when we get up to the really good stuff.


print("Hello,World");
跨行
print("Hello,
        world"); 输出结果有空格,跨行。
如果 想在排版时跨行,但输出时不想有空格 可使用normalized来排版
value message= "Hello,
                              World";
print(message.normalized);//输出结果不在是第一次跨行时,有空格的情况,而是输出Hello,World.

(二)文档注释
/*注释方式1*/
//注释方式2
第三种方式,个人测试出错,未找到原因
doc("The classic Hello World program")
by("Trompon the Elephant")
see(`function goodbye`)
throws(`class IOException`)
shared void hello()
{
print("hello,world');
}
其他注释
""双引号注释,在文件第一行。
(三)转义字符
print("\"Hello!\",said the program ");
\,\n,\t,\\等

三个"""sdfsdfs"""
print(""""Hello1",said the program.""");

print("Hello ,this is Ceylon ``language.version``
        running on ``runtime.name``   ``runtime.version`` !\n
        you ran me at ``system.milliseconds`` ms,
        with ``process.arguments.size``   arguments.");
 print("Hello,this is Ceylon "+language.version +
       "running on " + runtime.name +"    '  + runtime.version +"!\n" +
       "You ran me at " + system.milliseconds.string  +
       "ms ,  with  " +process.arguments.size.string +
       "arguments.");


String name = process.arguments.first; //compile error: String? is not assignable to String
String greeting = "Hello, ``name``!";
print(greeting);

String? name 
        = process.arguments.first;
String greeting;
if (exists name) {
    greeting = "Hello, ``name``!";
}
else {
    greeting = "Hello, World!";
}
print(greeting);


String greeting;
if (exists name 
        = process.arguments.first) {
    greeting = "Hello, ``name``!";
}
else {
    greeting = "Hello, World!";
}
print(greeting);


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值