當我使用.match和.eql?對於字符串比較,他們給了不同的結果ruby字符串比較.match vs .eql?
text_from_page = "wrong length (should be 64 characters)"
error_text = "wrong length (should be 64 characters)"
if(text_from_page.eql? error_text)
puts 'matched'
else
puts 'Not matched'
end
下面的比較沒有工作
if(text_from_page.match error_text)
puts 'matched'
else
puts 'Not matched'
end
有誰知道這樣做的原因是什麼?