mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
hash.c: compare methods [ci skip]
* hash.c (rb_hash_{le,lt,ge,gt}): [DOC] for [Feature #10984] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fb7ccd690e
commit
59a3fe5846
1 changed files with 52 additions and 0 deletions
52
hash.c
52
hash.c
|
@ -2734,6 +2734,19 @@ hash_le(VALUE hash1, VALUE hash2)
|
|||
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)
|
|||
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)
|
|||
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)
|
|||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue