I have a Rails project and one of my classes has:
def include_stuff?(str)
str.include? '.' || str.include? '-'
end
Which just give me:
syntax error, unexpected tSTRING_BEG, expecting keyword_end (SyntaxError)
cpf.include? '.' || cpf.include? '-'
^
I changed the code to:
def include_stuff?(str)
str.include? '.' or str.include? '-'
end
And no error was thrown.
I tried this too, with success:
def include_stuff?(str)
str.include?('.') || str.include?('-')
end
Why can't Ruby understand the statement with double pipe, but can understand the statement with the or
operator.
I'm using Ruby 2.2.2