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
を 1 文字としてカウントし、最初の行の前に 1 つ、最後に 1 つ、次に 2 行目の最後にあると見なされるため、これはEOS
当てはまります。行と1行目の後の1つ?つまり、なぜ前者が54で後者が53なのか?