I have some code. It should remove a trailing +
from a string if present:
def remove_prefix(number)
number.start_with? '+' ? number[1..-1] : number
end
But it doesn't work as expected – it just returns false
:
remove_prefix('123') #=> false
remove_prefix('+123') #=> false
Rubocop shows this error:
Lint/LiteralAsCondition: Literal '+' appeared as a condition.
What am I doing wrong?