你好世界
你好,世界
using "std" -> std;
fn main() -> int {
std.println("Hello, world!");
return 0;
}
你好,循环
using "std" -> std;
fn main() -> int {
var i = 0;
while (i < 10) {
std.println("Hello, while loop!");
i++;
}
for (var i = 0; i < 10; i++) {
std.println("Hello, for loop!");
}
for (a : 0..9) {
std.println("Hello, range-based for loop!");
}
return 0;
}
你好,函数
using "std" -> std;
fn foo() {
std.println("Hello, foo!");
}
fn bar() {
std.println("Hello, bar!");
}
fn main() -> int {
std.println("Hello, main!");
foo();
bar();
return 0;
}