long_string = <<EOS
It was the best of times,
It was the worst of times.
EOS
返回 53。为什么?空格算不算?即便如此。我们如何得到 53?
这个怎么样?
def test_flexible_quotes_can_handle_multiple_lines
long_string = %{
It was the best of times,
It was the worst of times.
}
assert_equal 54, long_string.size
end
def test_here_documents_can_also_handle_multiple_lines
long_string = <<EOS
It was the best of times,
It was the worst of times.
EOS
assert_equal 53, long_string.size
end
是这种情况吗,因为 %{ 案例将每个字符都计/n
为一个字符,并且在第一行之前被认为是一个字符,在末尾一个,然后在第二行末尾,而在这种EOS
情况下,在第一行之前只有一个行和第一行之后的一个?也就是说,为什么前者是54,而后者是53?