From dacf977a42b7268cc752fe0b3b521d39ab7b05e9 Mon Sep 17 00:00:00 2001 From: duerst Date: Tue, 29 Nov 2016 10:45:54 +0000 Subject: [PATCH] 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 --- string.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/string.c b/string.c index c007c7c69a..f2dab36d11 100644 --- a/string.c +++ b/string.c @@ -3130,6 +3130,8 @@ rb_str_cmp_m(VALUE str1, VALUE str2) * str.casecmp(other_str) -> -1, 0, +1 or nil * * Case-insensitive version of String#<=>. + * Currently, case-insensitivity only works on characters A-Z/a-z, + * not all of Unicode. This is different from casecmp?. * * "abcdef".casecmp("abcde") #=> 1 * "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, * false if they are not equal, and nil if other_str is not a string. * - * "abcdef".casecmp("abcde") #=> false - * "aBcDeF".casecmp("abcdef") #=> true - * "abcdef".casecmp("abcdefg") #=> false - * "abcdef".casecmp("ABCDEF") #=> true + * "abcdef".casecmp?("abcde") #=> false + * "aBcDeF".casecmp?("abcdef") #=> true + * "abcdef".casecmp?("abcdefg") #=> false + * "abcdef".casecmp?("ABCDEF") #=> true + * "äöü".casecmp?("ÄÖÜ") #=> true */ static VALUE @@ -9637,6 +9640,8 @@ sym_cmp(VALUE sym, VALUE other) * sym.casecmp(other) -> -1, 0, +1 or nil * * Case-insensitive version of Symbol#<=>. + * Currently, case-insensitivity only works on characters A-Z/a-z, + * not all of Unicode. This is different from casecmp?. */ static VALUE