Reputation: 1631
I had this
return $(check-age-name-date($File) -or $(check-name-debugtxt($File) -and check-age-last-mod($File)))
looks very straight-forward to me, but I had to change it to:
if(check-age-name-date($File)) {
return $True
} else {
if(check-name-debugtxt($File)){
if(check-age-last-mod($File)){
return $True
}else{
return $False
}
} else {
return $False
}
}
it just never executed check-age-last-mod. If check-age-name-date was false and check-name-debugtxt was true, it just returns true without invoking check-age-last-mod at all!!! What's going on here?
To clarify, the first piece of code is broken, the second one works, but is way longer. I just want explanation, because I'm surely missing something fundamental here. I'm not comfortable using language where I don't understand it's predicate logic.
Upvotes: 1
Views: 46
Reputation: 22821
You need some more brackets:
return $((check-age-name-date($File)) -or ((check-name-debugtxt($File)) -and (check-age-last-mod($File))))
Simplistically what you have is:
$a -or ($b -and $c)
But because you're calling functions you need to evaluate the result of each of them before the comparison, therefore you need to wrap each function call in brackets too, so you have
(f($a)) -or ((f($b)) -and (f($c)))
And because you want to evaluate the entire thing, that also needs be wrapped in parenthesis
((f($a)) -or ((f($b)) -and (f($c))))
Upvotes: 2