[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>
Currently, ruby/spec is maintained mostly by individuals and enjoys the
13 messages
2016/12/13
[#78963] Re: ruby/spec needs help from CRuby committers
— Urabe Shyouhei <shyouhei@...>
2017/01/04
I did ask attendees of last developer meeting to join this
[#78642] Re: ruby/spec needs help from CRuby committers
— Eric Wong <normalperson@...>
2016/12/14
Benoit Daloze <eregontp@gmail.com> wrote:
[ruby-core:78597] [Ruby trunk Feature#13025][Feedback] String equality operator does not perform implicit conversion
From:
nobu@...
Date:
2016-12-12 07:18:29 UTC
List:
ruby-core #78597
Issue #13025 has been updated by Nobuyoshi Nakada.
Tracker changed from Bug to Feature
Description updated
Status changed from Open to Feedback
What documentation do you refer?
The document of 2.3 says:
> If `obj` is not an instance of String but responds to `to_str`, then the
> two strings are compared using case equality `Object#===`.
(the method to be called is wrong, though)
Do you suggest changing the fallback method?
----------------------------------------
Feature #13025: String equality operator does not perform implicit conversion
https://bugs.ruby-lang.org/issues/13025#change-61981
* Author: John Carney
* Status: Feedback
* Priority: Normal
* Assignee:
----------------------------------------
According to the documentation, String#== should perform implicit conversion of non-strings, but this is not happening.
~~~ruby
class SomeClass
def initialize(value)
@value = value
end
def to_str
@value.to_s
end
end
"text" == SomeClass.new("text")
# => false (expected true)
~~~
Other operators work as expected:
~~~ruby
"text" + SomeClass.new("text")
# => "texttext"
"text" <=> SomeClass.new("text")
# => 0
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>