mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mrblib: add parentheses to method calls with used return values
added parentheses to all `to_enum` and `super` calls where the return value is used (returned, assigned, or passed to another method). this makes the code style consistent with the guideline that method calls should use parentheses when their return values are consumed. changes: - return to_enum :symbol -> return to_enum(:symbol) - return to_enum :symbol, arg -> return to_enum(:symbol, arg) - super message, name -> super(message, name) affected files: 10error.rb, array.rb, enum.rb, hash.rb, kernel.rb, numeric.rb, range.rb Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ class NoMethodError < NameError
|
||||
|
||||
def initialize(message=nil, name=nil, args=nil)
|
||||
@args = args
|
||||
super message, name
|
||||
super(message, name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@ class Array
|
||||
#
|
||||
# ISO 15.2.12.5.10
|
||||
def each(&block)
|
||||
return to_enum :each unless block
|
||||
return to_enum(:each) unless block
|
||||
|
||||
idx = 0
|
||||
while idx < length
|
||||
@@ -33,7 +33,7 @@ class Array
|
||||
#
|
||||
# ISO 15.2.12.5.11
|
||||
def each_index(&block)
|
||||
return to_enum :each_index unless block
|
||||
return to_enum(:each_index) unless block
|
||||
|
||||
idx = 0
|
||||
while idx < length
|
||||
@@ -54,7 +54,7 @@ class Array
|
||||
#
|
||||
# ISO 15.2.12.5.7
|
||||
def collect!(&block)
|
||||
return to_enum :collect! unless block
|
||||
return to_enum(:collect!) unless block
|
||||
|
||||
idx = 0
|
||||
len = size
|
||||
|
||||
+6
-6
@@ -57,7 +57,7 @@ module Enumerable
|
||||
#
|
||||
# ISO 15.3.2.2.3
|
||||
def collect(&block)
|
||||
return to_enum :collect unless block
|
||||
return to_enum(:collect) unless block
|
||||
|
||||
ary = []
|
||||
self.each{|*val| ary.push(block.call(*val))}
|
||||
@@ -73,7 +73,7 @@ module Enumerable
|
||||
#
|
||||
# ISO 15.3.2.2.4
|
||||
def detect(ifnone=nil, &block)
|
||||
return to_enum :detect, ifnone unless block
|
||||
return to_enum(:detect, ifnone) unless block
|
||||
|
||||
self.each{|*val|
|
||||
if block.call(*val)
|
||||
@@ -91,7 +91,7 @@ module Enumerable
|
||||
#
|
||||
# ISO 15.3.2.2.5
|
||||
def each_with_index(&block)
|
||||
return to_enum :each_with_index unless block
|
||||
return to_enum(:each_with_index) unless block
|
||||
|
||||
i = 0
|
||||
self.each{|*val|
|
||||
@@ -129,7 +129,7 @@ module Enumerable
|
||||
#
|
||||
# ISO 15.3.2.2.8
|
||||
def find_all(&block)
|
||||
return to_enum :find_all unless block
|
||||
return to_enum(:find_all) unless block
|
||||
|
||||
ary = []
|
||||
self.each{|*val|
|
||||
@@ -284,7 +284,7 @@ module Enumerable
|
||||
#
|
||||
# ISO 15.3.2.2.16
|
||||
def partition(&block)
|
||||
return to_enum :partition unless block
|
||||
return to_enum(:partition) unless block
|
||||
|
||||
ary_T = []
|
||||
ary_F = []
|
||||
@@ -306,7 +306,7 @@ module Enumerable
|
||||
#
|
||||
# ISO 15.3.2.2.17
|
||||
def reject(&block)
|
||||
return to_enum :reject unless block
|
||||
return to_enum(:reject) unless block
|
||||
|
||||
ary = []
|
||||
self.each{|*val|
|
||||
|
||||
+7
-7
@@ -52,7 +52,7 @@ class Hash
|
||||
#
|
||||
# ISO 15.2.13.4.9
|
||||
def each(&block)
|
||||
return to_enum :each unless block
|
||||
return to_enum(:each) unless block
|
||||
|
||||
keys = self.keys
|
||||
vals = self.values
|
||||
@@ -85,7 +85,7 @@ class Hash
|
||||
#
|
||||
# ISO 15.2.13.4.10
|
||||
def each_key(&block)
|
||||
return to_enum :each_key unless block
|
||||
return to_enum(:each_key) unless block
|
||||
|
||||
self.keys.each{|k| block.call(k)}
|
||||
self
|
||||
@@ -110,7 +110,7 @@ class Hash
|
||||
#
|
||||
# ISO 15.2.13.4.11
|
||||
def each_value(&block)
|
||||
return to_enum :each_value unless block
|
||||
return to_enum(:each_value) unless block
|
||||
|
||||
self.values.each{|v| block.call(v)}
|
||||
self
|
||||
@@ -165,7 +165,7 @@ class Hash
|
||||
# 1.8/1.9 Hash#reject! returns Hash; ISO says nothing.
|
||||
#
|
||||
def reject!(&block)
|
||||
return to_enum :reject! unless block
|
||||
return to_enum(:reject!) unless block
|
||||
|
||||
keys = []
|
||||
self.each{|k,v|
|
||||
@@ -196,7 +196,7 @@ class Hash
|
||||
# 1.8/1.9 Hash#reject returns Hash; ISO says nothing.
|
||||
#
|
||||
def reject(&block)
|
||||
return to_enum :reject unless block
|
||||
return to_enum(:reject) unless block
|
||||
|
||||
h = {}
|
||||
self.each{|k,v|
|
||||
@@ -218,7 +218,7 @@ class Hash
|
||||
# 1.9 Hash#select! returns Hash; ISO says nothing.
|
||||
#
|
||||
def select!(&block)
|
||||
return to_enum :select! unless block
|
||||
return to_enum(:select!) unless block
|
||||
|
||||
keys = []
|
||||
self.each{|k,v|
|
||||
@@ -249,7 +249,7 @@ class Hash
|
||||
# 1.9 Hash#select returns Hash; ISO says nothing
|
||||
#
|
||||
def select(&block)
|
||||
return to_enum :select unless block
|
||||
return to_enum(:select) unless block
|
||||
|
||||
h = {}
|
||||
self.each{|k,v|
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ module Kernel
|
||||
#
|
||||
# ISO 15.3.1.3.29
|
||||
private def loop(&block)
|
||||
return to_enum :loop unless block
|
||||
return to_enum(:loop) unless block
|
||||
|
||||
while true
|
||||
yield
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ class Integer
|
||||
#
|
||||
# ISO 15.2.8.3.22
|
||||
def times(&block)
|
||||
return to_enum :times unless block
|
||||
return to_enum(:times) unless block
|
||||
|
||||
i = 0
|
||||
while i < self
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ class Range
|
||||
#
|
||||
# ISO 15.2.14.4.4
|
||||
def each(&block)
|
||||
return to_enum :each unless block
|
||||
return to_enum(:each) unless block
|
||||
|
||||
val = self.begin
|
||||
last = self.end
|
||||
|
||||
Reference in New Issue
Block a user