Ruby’s Heredoc has a line break at the end of the last line.

  question, ruby

Code snippet

arr1_str = <<EOT.gsub('\r\n', '')
 1,2
 EOT
 arr1 = arr1_str.split(',')
 arr2 = Array[3]
 
 puts (arr1 + arr2).join(',')
 puts (arr1 + arr2).include?  ('2')

Output

1,2
 ,3
 false

supplement

This character is not\r\nAnd\r\n, solve.

Yes\nAt first gsub function used single quotation marks incorrectly, so it came to the wrong conclusion.

arr1_str = <<EOT.gsub('\n', '')
 1,2
 EOT
 
 puts arr1_str.gsub("\n", '')
 puts arr1_str.inspect

Output

1,2
 "1,2\n"