Being a hobbyist coder, I\'m lacking some fundamental knowledge. For the last couple days I\'ve been reading some stuff and the word \"predicate\" keeps reappearing. I\'d ve
A predicate isn't simply an expression that evaluates to true or false, there's more to it. The term "predicate" is used to refer to an expression that determines whether something is true or false. Or in other words, it makes an assertion and returns true or false based on that.
For example (in C#):
/*this is a predicate, as it's sole purpose is to make some
assertion about something.*/
bool IsNameBob(string name)
{
return name == "Bob";
}
/*Whereas this is not a predicate, as it's performing an action
then evaluating to true if it succeeds. */
bool DoSomethingCool() {
try
{
ImDoingSomethingCool();
}
catch
{
return false;
}
return true;
}
I understand what I've put here is purely a difference in semantics, but that's what this question was about right? Semantics?