From 2e71944f2bae2203aedb0ab7ea7ac72920d83d13 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 4 Dec 2025 19:21:32 +0900 Subject: [PATCH] mruby-enum-ext: add parentheses to to_enum calls added parentheses to all to_enum calls where the return value is used. Co-authored-by: Claude --- mrbgems/mruby-enum-ext/mrblib/enum.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mrbgems/mruby-enum-ext/mrblib/enum.rb b/mrbgems/mruby-enum-ext/mrblib/enum.rb index 424a7055d..26dc5f693 100644 --- a/mrbgems/mruby-enum-ext/mrblib/enum.rb +++ b/mrbgems/mruby-enum-ext/mrblib/enum.rb @@ -36,7 +36,7 @@ module Enumerable # a.drop_while {|i| i < 3 } #=> [3, 4, 5, 0] def drop_while(&block) - return to_enum :drop_while unless block + return to_enum(:drop_while) unless block ary, state = [], false self.each do |*val| @@ -83,7 +83,7 @@ module Enumerable # a.take_while {|i| i < 3 } #=> [1, 2] # def take_while(&block) - return to_enum :take_while unless block + return to_enum(:take_while) unless block ary = [] self.each do |*val| @@ -169,7 +169,7 @@ module Enumerable # (1..6).group_by {|i| i%3} #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]} # def group_by(&block) - return to_enum :group_by unless block + return to_enum(:group_by) unless block h = {} self.each do |*val| @@ -190,7 +190,7 @@ module Enumerable # # If no block is given, an enumerator is returned instead. def sort_by(&block) - return to_enum :sort_by unless block + return to_enum(:sort_by) unless block self.to_a.sort_by(&block) end @@ -268,7 +268,7 @@ module Enumerable # [1, 2, 3, 4].flat_map { |e| [e, -e] } #=> [1, -1, 2, -2, 3, -3, 4, -4] # [[1, 2], [3, 4]].flat_map { |e| e + [100] } #=> [1, 2, 100, 3, 4, 100] def flat_map(&block) - return to_enum :flat_map unless block + return to_enum(:flat_map) unless block ary = [] self.each do |*e| @@ -296,7 +296,7 @@ module Enumerable # %w[albatross dog horse].max_by {|x| x.length } #=> "albatross" def max_by(&block) - return to_enum :max_by unless block + return to_enum(:max_by) unless block first = true max = nil @@ -330,7 +330,7 @@ module Enumerable # %w[albatross dog horse].min_by {|x| x.length } #=> "dog" def min_by(&block) - return to_enum :min_by unless block + return to_enum(:min_by) unless block first = true min = nil @@ -404,7 +404,7 @@ module Enumerable # %w(albatross dog horse).minmax_by { |x| x.length } #=> ["dog", "albatross"] def minmax_by(&block) - return to_enum :minmax_by unless block + return to_enum(:minmax_by) unless block max = nil max_cmp = nil @@ -619,7 +619,7 @@ module Enumerable # def reverse_each(&block) - return to_enum :reverse_each unless block + return to_enum(:reverse_each) unless block ary = self.to_a i = ary.size - 1 @@ -920,7 +920,7 @@ end class Array def sort_by(&block) - return to_enum :sort_by unless block + return to_enum(:sort_by) unless block ary = [] self.each_with_index{|e, i|