https://play.crystal-lang.org/#/r/64ml
test = "hello\nhi"
pp test
pp test.includes? "n"
As we can see, the line feed \n
is printed on line 3, we can confirm that because pp
’s output is:
"hello\n" + "hi"
(see the +
)
however, in the docs, it says:
https://crystal-lang.org/api/0.27.0/String.html#includes%3F(search%3AChar|String)-instance-method
Returns
true
if the string contains search .
I asked gitter about this last week or so, but my head still explodes when I see this code.
Do the combination of letters \
and n
get converted into a line feed when read, making the n
disappear? Thus returning false? But, at the same time, the letters \
and n
are inside a string
edit: I think my first hypothesis is correct, because if you look here Carcin, it returns true. Because \z
isn’t a carriage, line feed, etc?