Hello. I need to write a function that returns a boolean value, which I can then use in an IF statement. I'm not entirely sure how to implement this correctly.
Could someone please provide an example of how this can be done? Any help or guidance would be greatly appreciated!
Solved! Go to Solution.
Solved by icse. Go to Solution.
Can you tell us in detail what your goal is?
heres an example of a function that returns a boolean value:
function main() {
bool $yourBool = 0
call yourFunction($yourBool)
if $yourBool {
message info "True"
} else {
message info "False"
}
}
function yourFunction(output bool $b) {
$b = 1
}
when you call yourFunction in the main method the value gets changed to true.
What would be macro alternative to this python code?:
def is_even(number):
if number % 2 == 0:
return True
else:
return False
number_to_check = 4
if is_even(number_to_check):
print("even")
else:
print("odd")
i cant test it atm but it should look something like this:
function is_even(int $number, output bool $result) {
if ($number % 2) == 0 {
$result = True
} else {
$result = False
}
}
function main() {
int $number_to_check = 4
bool $even = 0
Call is_even($number_to_check,$even)
if $even {
message info "Even"
} else {
message info "Odd"
}
}
Can't find what you're looking for? Ask the community or share your knowledge.