Conversation
|
I couldn't find a |
There was a problem hiding this comment.
Hello @KingsleyMcSimon
- There is an error in your code
$ ruby -wc Enumerable_Methods.rb
Enumerable_Methods.rb:100: syntax error, unexpected keyword_elsif, expecting keyword_end
elsif block_given?
^~~~~
Enumerable_Methods.rb:105: warning: mismatched indentations at 'end' with 'if' at 92
Enumerable_Methods.rb:107: warning: mismatched indentations at 'end' with 'if' at 87
Enumerable_Methods.rb:139: warning: assigned but unused variable - myinject
Enumerable_Methods.rb:226: syntax error, unexpected end-of-input, expecting keyword_end- Please, rewrite your my_inject method.
Please, read the comments below to know where are the bug to fix. Make the changes and submit a new code review request.
Thanks
| def my_each #This is my_each method | ||
| a = 0 | ||
| self.size.times do | ||
| yield(self[a]) | ||
| a += 1 | ||
|
|
||
| end | ||
|
|
||
| self | ||
| end |
There was a problem hiding this comment.
Should return an enumerator
irb(main):009:0> array.each
=> #<Enumerator: [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]:each>
irb(main):010:0> array.my_each
Traceback (most recent call last):
5: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
4: from (irb):10
3: from Enumerable_Methods.rb:10:in `my_each'
2: from Enumerable_Methods.rb:10:in `times'
1: from Enumerable_Methods.rb:11:in `block in my_each'
LocalJumpError (no block given (yield))
irb(main):011:0> | def my_each_with_index #my_each_with_index | ||
| a = 0 | ||
| self.size.times do | ||
| yield(self[a], a) | ||
| a += 1 | ||
| end | ||
|
|
||
| self | ||
|
|
||
| end |
There was a problem hiding this comment.
Should return an enumerator
irb(main):014:0> array.each_with_index
=> #<Enumerator: [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]:each_with_index>
irb(main):015:0> array.my_each_with_index
Traceback (most recent call last):
5: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
4: from (irb):15
3: from Enumerable_Methods.rb:21:in `my_each_with_index'
2: from Enumerable_Methods.rb:21:in `times'
1: from Enumerable_Methods.rb:22:in `block in my_each_with_index'
LocalJumpError (no block given (yield))
irb(main):016:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):017:0> | def my_select #my_select method | ||
| myselect = [] | ||
| self.my_each do |b| | ||
| if yield (b) | ||
| myselect.push (b) | ||
|
|
||
| end | ||
|
|
||
| end | ||
|
|
||
| myselect | ||
|
|
||
| end |
There was a problem hiding this comment.
Should return an enumerator
irb(main):019:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):020:0> array.select
=> #<Enumerator: [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]:select>
irb(main):021:0> array.my_select
Traceback (most recent call last):
7: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
6: from (irb):21
5: from Enumerable_Methods.rb:32:in `my_select'
4: from Enumerable_Methods.rb:10:in `my_each'
3: from Enumerable_Methods.rb:10:in `times'
2: from Enumerable_Methods.rb:11:in `block in my_each'
1: from Enumerable_Methods.rb:33:in `block in my_select'
LocalJumpError (no block given (yield))
irb(main):022:0> | def my_all? #my_all method | ||
| myall = [] | ||
| output = true | ||
| self.my_each do |b| | ||
| if yield (b) | ||
| myall.push (b) | ||
| end | ||
| end | ||
| if myall.length == self.length | ||
| output = true | ||
| else | ||
| output = false | ||
| end | ||
| output | ||
| end |
There was a problem hiding this comment.
irb(main):026:0> true_array = [1, true, 'hi', []]
=> [1, true, "hi", []]
irb(main):027:0> true_array.all?
=> true
irb(main):028:0> true_array.my_all?
Traceback (most recent call last):
7: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
6: from (irb):28
5: from Enumerable_Methods.rb:47:in `my_all?'
4: from Enumerable_Methods.rb:10:in `my_each'
3: from Enumerable_Methods.rb:10:in `times'
2: from Enumerable_Methods.rb:11:in `block in my_each'
1: from Enumerable_Methods.rb:48:in `block in my_all?'
LocalJumpError (no block given (yield))
irb(main):029:0> There was a problem hiding this comment.
irb(main):031:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):032:0> array.all?(Integer)
=> true
irb(main):033:0> array.my_all?(Integer)
Traceback (most recent call last):
3: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
2: from (irb):33
1: from Enumerable_Methods.rb:44:in `my_all?'
ArgumentError (wrong number of arguments (given 1, expected 0))
irb(main):034:0> There was a problem hiding this comment.
irb(main):042:0> words
=> ["dog", "door", "rod", "blade"]
irb(main):043:0> words.all?(/d/)
=> true
irb(main):044:0> words.my_all?(/d/)
Traceback (most recent call last):
3: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
2: from (irb):44
1: from Enumerable_Methods.rb:44:in `my_all?'
ArgumentError (wrong number of arguments (given 1, expected 0))
irb(main):045:0> There was a problem hiding this comment.
irb(main):047:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):048:0> array.all?(3)
=> false
irb(main):049:0> array.my_all?(3)
Traceback (most recent call last):
3: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
2: from (irb):49
1: from Enumerable_Methods.rb:44:in `my_all?'
ArgumentError (wrong number of arguments (given 1, expected 0))
irb(main):050:0>| def my_any? #my_any? method | ||
| output = false | ||
| self.my_each do |b| | ||
| if yield (b) | ||
| output = true | ||
| break | ||
|
|
||
| end | ||
|
|
||
| end | ||
| output | ||
| end |
There was a problem hiding this comment.
irb(main):052:0> true_array = [nil, false, true, []]
=> [nil, false, true, []]
irb(main):053:0> true_array.any?
=> true
irb(main):054:0> true_array.my_any?
Traceback (most recent call last):
7: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
6: from (irb):54
5: from Enumerable_Methods.rb:62:in `my_any?'
4: from Enumerable_Methods.rb:10:in `my_each'
3: from Enumerable_Methods.rb:10:in `times'
2: from Enumerable_Methods.rb:11:in `block in my_each'
1: from Enumerable_Methods.rb:63:in `block in my_any?'
LocalJumpError (no block given (yield))
irb(main):055:0>There was a problem hiding this comment.
irb(main):057:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):058:0> array.any?(Integer)
=> true
irb(main):059:0> array.my_any?(Integer)
Traceback (most recent call last):
3: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
2: from (irb):59
1: from Enumerable_Methods.rb:60:in `my_any?'
ArgumentError (wrong number of arguments (given 1, expected 0))
irb(main):060:0>There was a problem hiding this comment.
irb(main):062:0> words
=> ["dog", "door", "rod", "blade"]
irb(main):063:0> words.any?(/z/)
=> false
irb(main):064:0> words.my_any?(/z/)
Traceback (most recent call last):
3: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
2: from (irb):64
1: from Enumerable_Methods.rb:60:in `my_any?'
ArgumentError (wrong number of arguments (given 1, expected 0))
irb(main):065:0>There was a problem hiding this comment.
irb(main):067:0> words[0] = 'cat'
=> "cat"
irb(main):068:0> words
=> ["cat", "door", "rod", "blade"]
irb(main):069:0> words.any?('cat')
=> true
irb(main):071:0> words.my_any?('cat')
Traceback (most recent call last):
3: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
2: from (irb):71
1: from Enumerable_Methods.rb:60:in `my_any?'
ArgumentError (wrong number of arguments (given 1, expected 0))
irb(main):072:0> | def my_none? #my_none methods | ||
| output = true | ||
| self.my_each do |b| | ||
| if yield (b) | ||
| output = false | ||
| break | ||
| end | ||
| end | ||
| output | ||
| end |
There was a problem hiding this comment.
irb(main):074:0> false_array = [nil, false, nil, false]
=> [nil, false, nil, false]
irb(main):075:0> false_array.none?
=> true
irb(main):076:0> false_array.my_none?
Traceback (most recent call last):
7: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
6: from (irb):76
5: from Enumerable_Methods.rb:75:in `my_none?'
4: from Enumerable_Methods.rb:10:in `my_each'
3: from Enumerable_Methods.rb:10:in `times'
2: from Enumerable_Methods.rb:11:in `block in my_each'
1: from Enumerable_Methods.rb:76:in `block in my_none?'
LocalJumpError (no block given (yield))
irb(main):077:0>There was a problem hiding this comment.
irb(main):079:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):080:0> array.none?(String)
=> true
irb(main):081:0> array.my_none?(String)
Traceback (most recent call last):
3: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
2: from (irb):81
1: from Enumerable_Methods.rb:73:in `my_none?'
ArgumentError (wrong number of arguments (given 1, expected 0))
irb(main):082:0> There was a problem hiding this comment.
irb(main):085:0> words = %w[dog door rod blade]
=> ["dog", "door", "rod", "blade"]
irb(main):086:0> words.none?(/z/)
=> true
irb(main):087:0> words.my_none?(/z/)
Traceback (most recent call last):
3: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
2: from (irb):87
1: from Enumerable_Methods.rb:73:in `my_none?'
ArgumentError (wrong number of arguments (given 1, expected 0))
irb(main):088:0> There was a problem hiding this comment.
irb(main):091:0> words[0] = 5
=> 5
irb(main):092:0> words.none?(5)
=> false
irb(main):093:0> words.my_none?(5)
Traceback (most recent call last):
3: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
2: from (irb):93
1: from Enumerable_Methods.rb:73:in `my_none?'
ArgumentError (wrong number of arguments (given 1, expected 0))
irb(main):094:0> words
=> [5, "door", "rod", "blade"]
irb(main):095:0> | def my_count parameter = nil #my_count method | ||
| mycount = 0 | ||
| self.my_each do |b| | ||
| if parameter != nil | ||
| if parameter == self[b] | ||
| mycount += 1 | ||
| end | ||
| else | ||
| if yield (b) | ||
| mycount += 1 | ||
| self.my_each do |element| | ||
| if parameter | ||
| if element == parameter | ||
| mycount += 1 | ||
| end | ||
| end | ||
| elsif block_given? | ||
| mycount += if yield(element) | ||
| else | ||
| mycount = self.length | ||
| end | ||
| end | ||
| mycount | ||
| end |
There was a problem hiding this comment.
irb(main):097:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):098:0> array.count
=> 100
irb(main):099:0> array.my_count
Traceback (most recent call last):
7: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
6: from (irb):99
5: from Enumerable_Methods.rb:86:in `my_count'
4: from Enumerable_Methods.rb:10:in `my_each'
3: from Enumerable_Methods.rb:10:in `times'
2: from Enumerable_Methods.rb:11:in `block in my_each'
1: from Enumerable_Methods.rb:92:in `block in my_count'
LocalJumpError (no block given (yield))
irb(main):100:0> There was a problem hiding this comment.
Should count the number of element not returning an array
irb(main):102:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):103:0> array.count(3)
=> 14
irb(main):104:0> array.my_count(3)
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):105:0> There was a problem hiding this comment.
irb(main):107:0> block = proc { |num| num < 6 }
=> #<Proc:0x000056229934e0b0@(irb):107>
irb(main):108:0> array.count(&block)
=> 65
irb(main):109:0> array.my_count(&block)
Traceback (most recent call last):
11: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
10: from (irb):109
9: from Enumerable_Methods.rb:86:in `my_count'
8: from Enumerable_Methods.rb:10:in `my_each'
7: from Enumerable_Methods.rb:10:in `times'
6: from Enumerable_Methods.rb:11:in `block in my_each'
5: from Enumerable_Methods.rb:94:in `block in my_count'
4: from Enumerable_Methods.rb:10:in `my_each'
3: from Enumerable_Methods.rb:10:in `times'
2: from Enumerable_Methods.rb:11:in `block in my_each'
1: from Enumerable_Methods.rb:100:in `block (2 levels) in my_count'
NoMethodError (undefined method `elif' for #<Array:0x00005622993417e8>)
irb(main):110:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):111:0> | def my_map #my_map method | ||
| mymap = [] | ||
| self.my_each do |b| | ||
| mymap.push yield(b) | ||
| end | ||
| mymap | ||
| end |
There was a problem hiding this comment.
Should return an enumerator when no block given
irb(main):113:0> array
=> [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]
irb(main):114:0> array.map
=> #<Enumerator: [4, 3, 1, 6, 3, 2, 1, 8, 6, 0, 2, 2, 5, 2, 8, 4, 1, 1, 1, 4, 1, 6, 7, 2, 2, 8, 5, 5, 2, 0, 6, 7, 4, 3, 5, 5, 4, 7, 4, 7, 8, 0, 5, 4, 8, 7, 6, 5, 2, 7, 0, 3, 7, 4, 3, 8, 7, 2, 3, 5, 7, 3, 3, 4, 8, 0, 1, 3, 3, 4, 4, 7, 5, 6, 6, 6, 3, 8, 8, 8, 3, 7, 6, 5, 0, 3, 3, 1, 0, 0, 8, 4, 2, 7, 0, 8, 6, 0, 2, 8]:map>
irb(main):115:0> array.my_map
Traceback (most recent call last):
7: from /home/elvisfosso/.rbenv/versions/2.5.1/bin/irb:11:in `<main>'
6: from (irb):115
5: from Enumerable_Methods.rb:114:in `my_map'
4: from Enumerable_Methods.rb:10:in `my_each'
3: from Enumerable_Methods.rb:10:in `times'
2: from Enumerable_Methods.rb:11:in `block in my_each'
1: from Enumerable_Methods.rb:115:in `block in my_map'
LocalJumpError (no block given (yield))
irb(main):116:0>|
I couldn't find a |
bolah2009
left a comment
There was a problem hiding this comment.
Hey @KingsleyMcSimon
Please let's address issues raised by @maelfosso in the previous reviews also check the comments below on how to setup linter on this repo.
♻️ Make these changes and submit another code review request. 👍
Feel free to reach me on slack if you having issues implementing these features. 👍
Good luck with your next submission. 🌟
Cheers
Bola
PS: Note that comments tagged as OPTIONAL are not part of the minimum requirements to approve this PR
| # Link to the project on Github: | ||
|
|
||
| https://github.com/KingsleyMcSimon/Enumerable-Methods | ||
|
|
There was a problem hiding this comment.
Let's add a more descriptive readme. Details like assignment link (from Odin), list of custom methods built, their functions with examples and what was learned during the project can make the readme more descriptive.
| #arraysofnumbers = [1, 4, 5, 3, 2] | ||
| #puts multiply_els(arraysofnumbers) | ||
|
|
||
|
|
There was a problem hiding this comment.
Let's add .stickler.yml file to the root of the project. Also let's use this file. 👇
linters:
rubocop:
display_cop_names: true
files:
ignore:
- "bin/*"
- "db/*"
- "config/*"
- "Guardfile"
- "Rakefile"- Also, we need to add the
.rubocop.ymlfile, this can be found here
Remember that
.stickler.ymland.rubocop.ymlfile names start with a dot
If you are having an issue with setting up linter, read the Troubleshooting section of this repo.
You can run the linter locally: 💥 - run rubocop in your local env:
- add `gem 'rubocop'` to `Gemfile` (not sure how to use Gemfile? Read [this](https://bundler.io/v1.15/guides/bundler_setup.html)) - run `bundle install` - copy [.rubocop.yml](https://github.com/microverseinc/linters-config/blob/master/ruby/.rubocop.yml) to the root directory of your project - run `rubocop` - fix linter errors - **Remember to let your Code Reviewer know that you had problems with Stickler and you used linter in local env.**
Note: You can auto-fix common (fixable) style rules with rubocop -a
| mycount += 1 | ||
| end | ||
| end | ||
| elsif block_given? |
There was a problem hiding this comment.
Can you investigate this line? It's causing an error. Please let's fix this.
There was a problem hiding this comment.
syntax error, unexpected elsif, expecting end elsif block_given?
|
I couldn't find a |
stratospherique
left a comment
There was a problem hiding this comment.
Hi @KingsleyMcSimon 👋 It's seems that you're having some difficulties with the project since it''s been days since it was reviewed. See the code comments below and try to fix the issues because they are syntax related and surely you are capable of fixing them ⬇️
- If you found yourself stuck, reach out to one of the full time TSE to help you getting the project done 🤓
That's it ☺️ When finished, kindly resubmit another code review request 🙏
Happy coding ✌️
Ahmed Mahfoudh
|
|
||
| def my_inject #my_inject method | ||
| output = nil | ||
| my_each = output ? yield (output, b) : self |0| |
There was a problem hiding this comment.
This a ruby syntax error. 🙏 fix it
There was a problem hiding this comment.
syntax error, unexpected ( arg, expecting ':' ... my_each = output ? yield (output, b) : self |0|syntax error, unexpected ')', expecting '=' ...ch = output ? yield (output, b) : self |0|
| mycount += 1 | ||
| end | ||
| end | ||
| elsif block_given? |
There was a problem hiding this comment.
syntax error, unexpected elsif, expecting end elsif block_given?
|
|
||
| #Testing for my_each method | ||
| #(To test each of these methods, you can take it out of the comment and go ahead with the testing ) | ||
|
|
There was a problem hiding this comment.
- [REQUIRED] Remove all the debugging related code (commented code)
There was a problem hiding this comment.
Hi, i think i have implemented some of these changes and have them in the feature_branch in this repo
| my_inject {|mult, b | mult + b} | ||
|
|
||
| end | ||
| end |
There was a problem hiding this comment.
syntax error, unexpected end end
No description provided.