diff --git a/ChangeLog b/ChangeLog index 271b135b81..7ca49b585d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Aug 6 20:44:07 2014 Akinori MUSHA + + * 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 * lib/set.rb (Set#replace): Check if an object given is enumerable diff --git a/enum.c b/enum.c index d69a7aa9ba..7920b93c55 100644 --- a/enum.c +++ b/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 true if the block returns true - * exactly once. If the block is not given, one? will return - * true 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 true if the block returns true + * exactly once. If the block is not given, one? will return + * true 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) {