mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[DOC] Tweaks for String#eql?
This commit is contained in:
parent
ff6a8e95b7
commit
6d466a55bd
2 changed files with 19 additions and 11 deletions
18
doc/string/eql_p.rdoc
Normal file
18
doc/string/eql_p.rdoc
Normal file
|
@ -0,0 +1,18 @@
|
|||
Returns whether +self+ and +object+ have the same length and content:
|
||||
|
||||
s = 'foo'
|
||||
s.eql?('foo') # => true
|
||||
s.eql?('food') # => false
|
||||
s.eql?('FOO') # => false
|
||||
|
||||
Returns +false+ if the two strings' encodings are not compatible:
|
||||
|
||||
s0 = "äöü" # => "äöü"
|
||||
s1 = s0.encode(Encoding::ISO_8859_1) # => "\xE4\xF6\xFC"
|
||||
s0.encoding # => #<Encoding:UTF-8>
|
||||
s1.encoding # => #<Encoding:ISO-8859-1>
|
||||
s0.eql?(s1) # => false
|
||||
|
||||
See {Encodings}[rdoc-ref:encodings.rdoc].
|
||||
|
||||
Related: see {Querying}[rdoc-ref:String@Querying].
|
12
string.c
12
string.c
|
@ -4243,17 +4243,7 @@ rb_str_equal(VALUE str1, VALUE str2)
|
|||
* call-seq:
|
||||
* eql?(object) -> true or false
|
||||
*
|
||||
* Returns +true+ if +object+ has the same length and content;
|
||||
* as +self+; +false+ otherwise:
|
||||
*
|
||||
* s = 'foo'
|
||||
* s.eql?('foo') # => true
|
||||
* s.eql?('food') # => false
|
||||
* s.eql?('FOO') # => false
|
||||
*
|
||||
* Returns +false+ if the two strings' encodings are not compatible:
|
||||
*
|
||||
* "\u{e4 f6 fc}".encode(Encoding::ISO_8859_1).eql?("\u{c4 d6 dc}") # => false
|
||||
* :include: doc/string/eql_p.rdoc
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue