@@ -72,7 +72,7 @@ A procedure literal in Odin is defined with the proc keyword, following this `pr
7272``` odin
7373// basic procedure example
7474multiply :: proc(x: int, y: int) -> int {
75- return x * y
75+ return x * y
7676}
7777```
7878
@@ -113,8 +113,8 @@ usage of varying number of arguments:
113113
114114``` odin
115115sum :: proc(nums: ..int) -> int {
116- for n in nums do result += n
117- return result
116+ for n in nums do result += n
117+ return result
118118}
119119
120120sum() // 0
@@ -127,19 +127,19 @@ usage of named outputs:
127127``` odin
128128// without named output
129129foo :: proc() -> int {
130- a := 10
131- return a
130+ a := 10
131+ return a
132132}
133133
134134// with named output
135135foo :: proc() -> (a: int) {
136- a = 10
136+ a = 10
137137}
138138
139139// with named output and naked return statement
140140foo :: proc() -> (a: int) {
141- a = 10
142- return // a return without arguments returns the named return value
141+ a = 10
142+ return // a return without arguments returns the named return value
143143}
144144```
145145
@@ -159,66 +159,66 @@ Various different loop examples:
159159``` odin
160160// basic loop
161161for i := 0; i < 10; i += 1 {
162- fmt.println(i)
162+ fmt.println(i)
163163}
164164
165165// while loop equivelant
166166for i < 10 {
167- fmt.println(i)
167+ fmt.println(i)
168168}
169169
170170// range loop
171171for i in 0..<10 {
172- fmt.println(i)
172+ fmt.println(i)
173173}
174174
175175// array loop (array/slice/dynamic/string/map)
176176for value in some_array {
177- fmt.println(value)
177+ fmt.println(value)
178178}
179179
180180// named index array loop
181181for value, index in some_array {
182- fmt.println(index, value)
182+ fmt.println(index, value)
183183}
184184
185185// named key and value map loop
186186for key, value in some_map {
187- fmt.println(key, value)
187+ fmt.println(key, value)
188188}
189189
190190// infinite loop
191191for {
192- fmt.println(i)
192+ fmt.println(i)
193193}
194194
195195// nested loop
196196for i := 0; i < 10; i += 1 {
197- for j := 0; j < 10; j += 1 {
197+ for j := 0; j < 10; j += 1 {
198198 fmt.println(i, j)
199199 }
200200}
201201
202202// nested array loop
203203for outer in outer_array {
204- for inner in inner_array {
204+ for inner in inner_array {
205205 fmt.println(inner, outer)
206206 }
207207}
208208
209209// reverse loop
210210#reverse for x in array {
211- fmt.println(x)
211+ fmt.println(x)
212212}
213213
214214// array loop by reference
215215for &value in some_array {
216- value = something // element can be modified
216+ value = something // element can be modified
217217}
218218
219219// map loop by referende (key can not be referenced)
220220for key, &value in some_map {
221- value += 1
221+ value += 1
222222}
223223
224224// single line loops with scope block
@@ -389,11 +389,11 @@ Here is an example of how to do function overloading:
389389
390390``` odin
391391bool_to_string :: proc(b: bool) -> string {
392- // convert bool to string
392+ // convert bool to string
393393}
394394
395395int_to_string :: proc(i: int) -> string {
396- // convert int to string
396+ // convert int to string
397397}
398398
399399// convert bool or int to string
@@ -544,7 +544,7 @@ Build in fields like `xyzw` and `rgba` are available on any array with a length
544544``` odin
545545Vector3 :: [3]f32
546546foo :: proc(a: Vector3) -> f32 {
547- return a.x + a.y + a.z // notice xyz is buildin
547+ return a.x + a.y + a.z // notice xyz is buildin
548548}
549549```
550550
0 commit comments