Skip to content

Commit 20c40c5

Browse files
committed
stickler updates
1 parent 7f62cd6 commit 20c40c5

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

module.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def my_all?(a=nil)
3030

3131
def my_any?(a=nil)
3232
my_each { |x| return yield(x) ? true : false } if block_given?
33-
my_each { |x| return a.match(x.to_s) ? true : false } if a.class == Regexp
34-
my_each { |x| return x.is_a?(a) ? true : false } if a.class == Class
33+
my_each { |x| return a.match(x.to_s) ? true : false } if a.class == Regexp
34+
my_each { |x| return x.is_a?(a) ? true : false } if a.class == Class
3535
my_each { |x| return x ? true : false } unless block_given?
3636
end
3737

@@ -61,8 +61,8 @@ def my_map
6161

6262
def my_inject(a=nil,b=nil)
6363
a.class == Numeric ? final = a : final = 0
64-
b = a if a != nil && b.nil?
65-
if b != nil || b != false
64+
b = a if !a.nil? && b.nil?
65+
if !b.nil? || b != false
6666
case b
6767
when :+
6868
my_each { |y| final += y }
@@ -72,21 +72,19 @@ def my_inject(a=nil,b=nil)
7272
return final
7373
when :*
7474
final = 1 if final != 0
75-
my_each { |y| final*=y }
75+
my_each { |y| final *= y }
7676
return final
7777
when :/
7878
my_each { |y| final /= y }
7979
return final
8080
end
8181
end
82-
if block_given?
83-
final = 1 if yield(final, self[0]) == 0 || yield(final, self[1]) == 0 if self[1] != nil
84-
my_each { |x| final = yield(final, x) }
85-
return final
86-
end
82+
final = 1 if yield(final, self[0]) == 0 || yield(final, self[1]) == 0 if self[1] != nil if block_given?
83+
my_each { |x| final = yield(final, x) } if block_given?
84+
return final if block_given?
8785
end
8886
end
8987

9088
def multiply_els(x)
91-
x.my_inject(:+)
92-
end
89+
x.my_inject(:*)
90+
end

0 commit comments

Comments
 (0)