Let's suppose I have some sort of form that automatically performs a copy procedure when the user either focuses on a textbox, or highlights some text.
Let's suppose that the user has a preference of copying on focus or copying on highlight. By default, it copies on highlight... which leads us to this code
if(copyOnFocus ? hasFocus : isHighlighted) {
copy();
}
I understand this code without any problem, but I have this nagging feeling that this is a bad idea because I've never seen a ternary inside of an if condition before.
Is this ok, or should it be refactored? If it needs to be refactored, what would you suggest?