mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Move enum.one? documentation before the relevant method.
* enum.c (enum_one): Move enum.one? documentation before the relevant method. Submitted by @vipulnsward. [Fixes GH-687] https://github.com/ruby/ruby/pull/687 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
305be780df
commit
f76e390ed6
2 changed files with 23 additions and 18 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Aug 6 20:44:07 2014 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* enum.c (enum_one): Move enum.one? documentation before the
|
||||
relevant method. Submitted by @vipulnsward. [Fixes GH-687]
|
||||
https://github.com/ruby/ruby/pull/687
|
||||
|
||||
Wed Aug 6 20:25:47 2014 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* lib/set.rb (Set#replace): Check if an object given is enumerable
|
||||
|
|
35
enum.c
35
enum.c
|
@ -1105,24 +1105,6 @@ DEFINE_ENUMFUNCS(one)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* enum.one? [{ |obj| block }] -> true or false
|
||||
*
|
||||
* Passes each element of the collection to the given block. The method
|
||||
* returns <code>true</code> if the block returns <code>true</code>
|
||||
* exactly once. If the block is not given, <code>one?</code> will return
|
||||
* <code>true</code> only if exactly one of the collection members is
|
||||
* true.
|
||||
*
|
||||
* %w{ant bear cat}.one? { |word| word.length == 4 } #=> true
|
||||
* %w{ant bear cat}.one? { |word| word.length > 4 } #=> false
|
||||
* %w{ant bear cat}.one? { |word| word.length < 4 } #=> false
|
||||
* [ nil, true, 99 ].one? #=> false
|
||||
* [ nil, true, false ].one? #=> true
|
||||
*
|
||||
*/
|
||||
|
||||
struct nmin_data {
|
||||
long n;
|
||||
long bufmax;
|
||||
|
@ -1307,6 +1289,23 @@ nmin_run(VALUE obj, VALUE num, int by, int rev)
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* enum.one? [{ |obj| block }] -> true or false
|
||||
*
|
||||
* Passes each element of the collection to the given block. The method
|
||||
* returns <code>true</code> if the block returns <code>true</code>
|
||||
* exactly once. If the block is not given, <code>one?</code> will return
|
||||
* <code>true</code> only if exactly one of the collection members is
|
||||
* true.
|
||||
*
|
||||
* %w{ant bear cat}.one? { |word| word.length == 4 } #=> true
|
||||
* %w{ant bear cat}.one? { |word| word.length > 4 } #=> false
|
||||
* %w{ant bear cat}.one? { |word| word.length < 4 } #=> false
|
||||
* [ nil, true, 99 ].one? #=> false
|
||||
* [ nil, true, false ].one? #=> true
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
enum_one(VALUE obj)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue