mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Update demo.odin
This commit is contained in:
+13
-8
@@ -113,6 +113,9 @@ the_basics :: proc() {
|
|||||||
// Constants can be explicitly typed like a variable declaration:
|
// Constants can be explicitly typed like a variable declaration:
|
||||||
Y : int : 123;
|
Y : int : 123;
|
||||||
Z :: Y + 7; // constant computations are possible
|
Z :: Y + 7; // constant computations are possible
|
||||||
|
|
||||||
|
_ = my_integer_variable;
|
||||||
|
_ = x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,15 +154,15 @@ control_flow :: proc() {
|
|||||||
|
|
||||||
// Range-based for loop
|
// Range-based for loop
|
||||||
// The basic for loop
|
// The basic for loop
|
||||||
for i := 0; i < 10; i += 1 {
|
for j := 0; j < 10; j += 1 {
|
||||||
fmt.println(i);
|
fmt.println(j);
|
||||||
}
|
}
|
||||||
// can also be written
|
// can also be written
|
||||||
for i in 0..<10 {
|
for j in 0..<10 {
|
||||||
fmt.println(i);
|
fmt.println(j);
|
||||||
}
|
}
|
||||||
for i in 0..9 {
|
for j in 0..9 {
|
||||||
fmt.println(i);
|
fmt.println(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Certain built-in types can be iterated over
|
// Certain built-in types can be iterated over
|
||||||
@@ -256,7 +259,7 @@ control_flow :: proc() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch i := 0; i {
|
switch j := 0; j {
|
||||||
case 0:
|
case 0:
|
||||||
case one_angry_dwarf():
|
case one_angry_dwarf():
|
||||||
}
|
}
|
||||||
@@ -827,6 +830,7 @@ implicit_context_system :: proc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my_custom_allocator :: mem.nil_allocator;
|
my_custom_allocator :: mem.nil_allocator;
|
||||||
|
_ = c;
|
||||||
|
|
||||||
// By default, the context value has default values for its parameters which is
|
// By default, the context value has default values for its parameters which is
|
||||||
// decided in the package runtime. What the defaults are are compiler specific.
|
// decided in the package runtime. What the defaults are are compiler specific.
|
||||||
@@ -1144,7 +1148,8 @@ map_type :: proc() {
|
|||||||
// can be done in two ways:
|
// can be done in two ways:
|
||||||
elem, ok := m["Bob"];
|
elem, ok := m["Bob"];
|
||||||
exists := "Bob" in m;
|
exists := "Bob" in m;
|
||||||
|
_ = elem;
|
||||||
|
_ = exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
implicit_selector_expression :: proc() {
|
implicit_selector_expression :: proc() {
|
||||||
|
|||||||
Reference in New Issue
Block a user