1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix/improve documentation of String/Symbol#casecmp[?]

Fix documentation of String#casecmp? (examples didn't have the '?').
Add an example with non-ASCII characters. Clarify that casecmp,
unlike casecmp?, only does case-insensitivity on A-Z/a-z.
[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
duerst 2016-11-29 10:45:54 +00:00
parent fa7066f818
commit dacf977a42

View file

@ -3130,6 +3130,8 @@ rb_str_cmp_m(VALUE str1, VALUE str2)
* str.casecmp(other_str) -> -1, 0, +1 or nil * str.casecmp(other_str) -> -1, 0, +1 or nil
* *
* Case-insensitive version of <code>String#<=></code>. * Case-insensitive version of <code>String#<=></code>.
* Currently, case-insensitivity only works on characters A-Z/a-z,
* not all of Unicode. This is different from <code>casecmp?</code>.
* *
* "abcdef".casecmp("abcde") #=> 1 * "abcdef".casecmp("abcde") #=> 1
* "aBcDeF".casecmp("abcdef") #=> 0 * "aBcDeF".casecmp("abcdef") #=> 0
@ -3202,10 +3204,11 @@ rb_str_casecmp(VALUE str1, VALUE str2)
* Returns true if str and other_other_str are equal after Unicode case folding, * Returns true if str and other_other_str are equal after Unicode case folding,
* false if they are not equal, and nil if other_str is not a string. * false if they are not equal, and nil if other_str is not a string.
* *
* "abcdef".casecmp("abcde") #=> false * "abcdef".casecmp?("abcde") #=> false
* "aBcDeF".casecmp("abcdef") #=> true * "aBcDeF".casecmp?("abcdef") #=> true
* "abcdef".casecmp("abcdefg") #=> false * "abcdef".casecmp?("abcdefg") #=> false
* "abcdef".casecmp("ABCDEF") #=> true * "abcdef".casecmp?("ABCDEF") #=> true
* "äöü".casecmp?("ÄÖÜ") #=> true
*/ */
static VALUE static VALUE
@ -9637,6 +9640,8 @@ sym_cmp(VALUE sym, VALUE other)
* sym.casecmp(other) -> -1, 0, +1 or nil * sym.casecmp(other) -> -1, 0, +1 or nil
* *
* Case-insensitive version of <code>Symbol#<=></code>. * Case-insensitive version of <code>Symbol#<=></code>.
* Currently, case-insensitivity only works on characters A-Z/a-z,
* not all of Unicode. This is different from <code>casecmp?</code>.
*/ */
static VALUE static VALUE