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

ruby-changes:40489

From: nobu <ko1@a...>
Date: Sat, 14 Nov 2015 17:13:20 +0900 (JST)
Subject: [ruby-changes:40489] nobu:r52570 (trunk): hash.c: compare methods [ci skip]

nobu	2015-11-14 17:13:11 +0900 (Sat, 14 Nov 2015)

  New Revision: 52570

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

  Log:
    hash.c: compare methods [ci skip]
    
    * hash.c (rb_hash_{le,lt,ge,gt}): [DOC] for [Feature #10984]

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 52569)
+++ hash.c	(revision 52570)
@@ -2734,6 +2734,19 @@ hash_le(VALUE hash1, VALUE hash2) https://github.com/ruby/ruby/blob/trunk/hash.c#L2734
     return args[1];
 }
 
+/*
+ * call-seq:
+ *   hash <= other -> true or false
+ *
+ * Returns <code>true</code> if <i>hash</i> is subset of
+ * <i>other</i> or equals to <i>other</i>.
+ *
+ *    h1 = {a:1, b:2}
+ *    h2 = {a:1, b:2, c:3}
+ *    h1 <= h2   #=> true
+ *    h2 <= h1   #=> false
+ *    h1 <= h1   #=> true
+ */
 static VALUE
 rb_hash_le(VALUE hash, VALUE other)
 {
@@ -2742,6 +2755,19 @@ rb_hash_le(VALUE hash, VALUE other) https://github.com/ruby/ruby/blob/trunk/hash.c#L2755
     return hash_le(hash, other);
 }
 
+/*
+ * call-seq:
+ *   hash < other -> true or false
+ *
+ * Returns <code>true</code> if <i>hash</i> is subset of
+ * <i>other</i>.
+ *
+ *    h1 = {a:1, b:2}
+ *    h2 = {a:1, b:2, c:3}
+ *    h1 < h2    #=> true
+ *    h2 < h1    #=> false
+ *    h1 < h1    #=> false
+ */
 static VALUE
 rb_hash_lt(VALUE hash, VALUE other)
 {
@@ -2750,6 +2776,19 @@ rb_hash_lt(VALUE hash, VALUE other) https://github.com/ruby/ruby/blob/trunk/hash.c#L2776
     return hash_le(hash, other);
 }
 
+/*
+ * call-seq:
+ *   hash >= other -> true or false
+ *
+ * Returns <code>true</code> if <i>other</i> is subset of
+ * <i>hash</i> or equals to <i>hash</i>.
+ *
+ *    h1 = {a:1, b:2}
+ *    h2 = {a:1, b:2, c:3}
+ *    h1 >= h2   #=> false
+ *    h2 >= h1   #=> true
+ *    h1 >= h1   #=> true
+ */
 static VALUE
 rb_hash_ge(VALUE hash, VALUE other)
 {
@@ -2758,6 +2797,19 @@ rb_hash_ge(VALUE hash, VALUE other) https://github.com/ruby/ruby/blob/trunk/hash.c#L2797
     return hash_le(other, hash);
 }
 
+/*
+ * call-seq:
+ *   hash > other -> true or false
+ *
+ * Returns <code>true</code> if <i>other</i> is subset of
+ * <i>hash</i>.
+ *
+ *    h1 = {a:1, b:2}
+ *    h2 = {a:1, b:2, c:3}
+ *    h1 > h2    #=> false
+ *    h2 > h1    #=> true
+ *    h1 > h1    #=> false
+ */
 static VALUE
 rb_hash_gt(VALUE hash, VALUE other)
 {

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

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