2
單引號字符串的轉義規則在以下示例中看起來不一致: Ruby轉義單引號字符串的確切規則是什麼?單引號字符串不一致的轉義行爲
p str1 = 'a\b\c'
#=> "a\\b\\c" looks fine, I know single quotes don't do escaping
p str2 = 'a\\b\\c'
#=> "a\\b\\c" hmm? It actually escapes
# Trying double quotes
p str3 = "a\b\c"
#=> Error, \c isn't valid
p str4 = "a\\b\\c"
#=> "a\\b\\c"
p str1 == str4, str2 == str4
# true, true