Most concise way to test string equality (not object equality) for Ruby strings or symbols?

后端 未结 2 1869
深忆病人
深忆病人 2021-02-01 11:30

I always do this to test string equality in Ruby:

if mystring.eql?(yourstring)
 puts \"same\"
else
 puts \"different\"
end

Is this is the corre

2条回答
  •  别那么骄傲
    2021-02-01 12:12

    According to http://www.techotopia.com/index.php/Ruby_String_Concatenation_and_Comparison

    Doing either

    mystring == yourstring

    or

    mystring.eql? yourstring

    Are equivalent.

提交回复
热议问题