我刚开始学习红宝石,这可能很容易解决.如何比较Ruby中的两个字符串?
我尝试过以下方法:
puts var1 == var2 //false, should be true (I think)
puts var1.eql?(var2) //false, should be true (I think)
Run Code Online (Sandbox Code Playgroud)
当我尝试将它们回显到控制台以便我可以直观地比较值时,我这样做:
puts var1 //prints "test content" without quotes
puts var2 //prints ["test content"] with quotes and braces
Run Code Online (Sandbox Code Playgroud)
最终这些不同类型的字符串如何比较这两个?