Skip to content

Commit 5d04972

Browse files
committed
Make code easier to read
1 parent 7949645 commit 5d04972

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

enumerables.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def my_none?(para = nil)
6666
to_a.my_each { |val| return false if val.is_a?(para) }
6767
elsif para
6868
to_a.my_each { |val| return false if val == para }
69-
else to_a.my_each { |val| return false if yield(val) }
69+
else
70+
to_a.my_each { |val| return false if yield(val) }
7071
end
7172
true
7273
end
@@ -88,7 +89,8 @@ def my_map(my_proc = nil)
8889
arr = []
8990
if my_proc
9091
to_a.my_each { |val| arr << my_proc.call(val) }
91-
else to_a.my_each { |val| arr << yield(val) }
92+
else
93+
to_a.my_each { |val| arr << yield(val) }
9294
end
9395
arr
9496
end
@@ -108,7 +110,8 @@ def my_inject(initial_1 = nil, initial_2 = nil)
108110
1.upto(to_a.length - 1) { |i| memo = yield(memo, to_a[i]) }
109111
elsif !block_given? && !initial_1
110112
raise LocalJumpError
111-
else return 'input error'
113+
else
114+
return 'input error'
112115
end
113116
memo
114117
end

0 commit comments

Comments
 (0)