18,700
edits
(→Functions: moving Concurrency section down since it is more advanced, and adding Looping section (I hope the part about "sleep" is correct)) |
m (→Returning: using strong syntax for "return"; wording) |
||
Line 432: | Line 432: | ||
{ | { | ||
var int the_result = input + 10; | var int the_result = input + 10; | ||
return the_result; | return(the_result); | ||
} | } | ||
Line 439: | Line 439: | ||
some_number = add_ten(enemy_count); | some_number = add_ten(enemy_count); | ||
Function return values can also be used in "if" statements to provide a true/false condition | Function return values can also be used in "if" statements to provide a true/false condition. If you have a function that returns a bool... | ||
func bool is_it_safe(void) | func bool is_it_safe(void) | ||
Line 445: | Line 445: | ||
var bool result = false; | var bool result = false; | ||
# do some investigation here and set result to true if it is safe | # do some investigation here and set result to true if it is safe | ||
return result; | return(result); | ||
} | } | ||
...then it could be called this way in some other function: | |||
if (is_it_safe()) | if (is_it_safe()) |