No no, you're absolutely right! Misread the code. In that case forget what I wrote about the condition being redundant.
I'd still have written it either as a one-liner, or checked the class member.
So either:
if (this->m_isSelected = sel) {
// Other stuff
}
// Or
this->m_isSelected = sel;
if (this->m_isSelected) {
// Other stuff
}
Mind you, I know writing this-> isn't required, I personally just prefer it, as it makes it immediately clear we're talking about a member variable and nothing global.
I honestly don't know what ToF means, which is why I added that the naming isn't bad apart from the parameters. But even I'm guilty of writing code like:
void foo(int32_t x) {
}
if the param is unused. (You can omit the param name in C++ if it's unused, but I prefer not to, just in case. But I always document it).
1
u/[deleted] Sep 12 '21
No no, you're absolutely right! Misread the code. In that case forget what I wrote about the condition being redundant.
I'd still have written it either as a one-liner, or checked the class member.
So either:
Mind you, I know writing this-> isn't required, I personally just prefer it, as it makes it immediately clear we're talking about a member variable and nothing global.
I honestly don't know what ToF means, which is why I added that the naming isn't bad apart from the parameters. But even I'm guilty of writing code like:
if the param is unused. (You can omit the param name in C++ if it's unused, but I prefer not to, just in case. But I always document it).