[前][次][番号順一覧][スレッド一覧]

ruby-changes:45813

From: stomar <ko1@a...>
Date: Sun, 12 Mar 2017 05:02:00 +0900 (JST)
Subject: [ruby-changes:45813] stomar:r57886 (trunk): docs for String#casecmp and String#casecmp?

stomar	2017-03-12 05:01:55 +0900 (Sun, 12 Mar 2017)

  New Revision: 57886

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57886

  Log:
    docs for String#casecmp and String#casecmp?
    
    * string.c: [DOC] specify when String#casecmp and String#casecmp?
      return nil; modify examples to better show difference to <=>;
      fix RDoc markup and typos.

  Modified files:
    trunk/string.c
Index: string.c
===================================================================
--- string.c	(revision 57885)
+++ string.c	(revision 57886)
@@ -3200,16 +3200,20 @@ rb_str_cmp_m(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L3200
 
 /*
  *  call-seq:
- *     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>.
  *  Currently, case-insensitivity only works on characters A-Z/a-z,
- *  not all of Unicode. This is different from <code>casecmp?</code>.
+ *  not all of Unicode. This is different from String#casecmp?.
  *
- *     "abcdef".casecmp("abcde")     #=> 1
+ *     "aBcDeF".casecmp("abcde")     #=> 1
  *     "aBcDeF".casecmp("abcdef")    #=> 0
- *     "abcdef".casecmp("abcdefg")   #=> -1
+ *     "aBcDeF".casecmp("abcdefg")   #=> -1
  *     "abcdef".casecmp("ABCDEF")    #=> 0
+ *
+ *  +nil+ is returned if the two strings have incompatible encodings.
+ *
+ *     "\u{e4 f6 fc}".encode("ISO-8859-1").casecmp("\u{c4 d6 dc}")   #=> nil
  */
 
 static VALUE
@@ -3274,14 +3278,18 @@ rb_str_casecmp(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L3278
  *  call-seq:
  *     str.casecmp?(other_str)   -> true, false, or nil
  *
- *  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.
+ *  Returns +true+ if +str+ and +other_str+ are equal after
+ *  Unicode case folding, +false+ if they are not equal.
  *
- *     "abcdef".casecmp?("abcde")     #=> false
+ *     "aBcDeF".casecmp?("abcde")     #=> false
  *     "aBcDeF".casecmp?("abcdef")    #=> true
- *     "abcdef".casecmp?("abcdefg")   #=> false
+ *     "aBcDeF".casecmp?("abcdefg")   #=> false
  *     "abcdef".casecmp?("ABCDEF")    #=> true
- *     "\u{e4 f6 fc}".casecmp?("\u{c4 d6 dc}") #=> true
+ *     "\u{e4 f6 fc}".casecmp?("\u{c4 d6 dc}")   #=> true
+ *
+ *  +nil+ is returned if the two strings have incompatible encodings.
+ *
+ *     "\u{e4 f6 fc}".encode("ISO-8859-1").casecmp?("\u{c4 d6 dc}")   #=> nil
  */
 
 static VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]