diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-25 15:12:12 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-25 15:12:12 +0000 |
| commit | 7d1944ab9d2307f2736afe8520436872db1c7617 (patch) | |
| tree | 7380a4f148f9ce0b70ed9f02cfa5e8561c783a7a /examples/data_structures/linked_list.zc | |
| parent | 8b720543f538862796fec0ff6b7ea12cb140bf0f (diff) | |
'let' it be
Diffstat (limited to 'examples/data_structures/linked_list.zc')
| -rw-r--r-- | examples/data_structures/linked_list.zc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/data_structures/linked_list.zc b/examples/data_structures/linked_list.zc index cb85554..cd16bf5 100644 --- a/examples/data_structures/linked_list.zc +++ b/examples/data_structures/linked_list.zc @@ -8,7 +8,7 @@ struct Node { impl Node { fn new(v: int) -> Self* { - var n = alloc<Node>(); + let n = alloc<Node>(); guard n != NULL else { "Out of memory!"; return NULL; @@ -29,7 +29,7 @@ impl LinkedList { } fn push(self, v: int) { - var new_node = Node::new(v); + let new_node = Node::new(v); guard new_node != NULL else { return; } new_node.next = self.head; @@ -37,7 +37,7 @@ impl LinkedList { } fn print_list(self) { - var current: Node* = self.head; + let current: Node* = self.head; "["..; while current != NULL { "{current.value}"..; @@ -50,17 +50,17 @@ impl LinkedList { } fn free(self) { - var current: Node* = self.head; + let current: Node* = self.head; while current != NULL { - autofree var temp = current; + autofree let temp = current; current = current.next; } self.head = NULL; } fn len(self) -> int { - var count = 0; - var current: Node* = self.head; + let count = 0; + let current: Node* = self.head; while current != NULL { count++; current = current.next; @@ -70,7 +70,7 @@ impl LinkedList { } fn main() { - var list = LinkedList::new(); + let list = LinkedList::new(); defer list.free(); "Pushing: 10, 20, 30..."; |
