comparing two strings in ruby

ruby

Solution

From what you printed, it seems `var2` is an array containing one string. Or actually, it appears to hold the result of running `.inspect` on an array containing one string. It would be helpful to show how you are initializing them.

irb(main):005:0* v1 = "test"
=> "test"
irb(main):006:0> v2 = ["test"]
=> ["test"]
irb(main):007:0> v3 = v2.inspect
=> "[\"test\"]"
irb(main):008:0> puts v1,v2,v3
test
test
["test"]

Problem

I've just started to learn ruby and this is probably very easy to solve. How do I compare two strings in Ruby? I've tried the following : ``` puts var1 == var2 //false, should be true (I think) puts var1.eql?(var2) //false, should be true (I think) ``` When I try to echo them to console so I can compare values visually, I do this : ``` puts var1 //prints "test content" without quotes puts var2 //prints ["test content"] with quotes and braces ``` Ultimately are these different types of strings of how do I compare these two?

Original source

Related problems