Conversation
There was a problem hiding this comment.
Great work implementing the suggested changes 👏 However, some methods doesn't meet with requirements. check below ⬇️
- [REQUIRED] Fix linter errors. They should be ✔️
Methods issues
my_each
- my_each returns an Enumerator if no block is given
array = [1,2,5,8,7,98,4] p array.my_each.class # not Enumerator
my_each_with_index
- my_each_with_index returns an enumerator if no block is given
array = [1,2,5,8,7,98,4] p array.my_each_with_index.class # not Enumerator
my_select
- my_select returns an array containing all elements of enum for which the given block returns a true value
block = proc {|x| x>4} array = [1,2,5,8,7,98,4] p array.my_select(&block) == array.select(&block) # false - my_select returns an enumerator if no block is given
array = [1,2,5,8,7,98,4] p array.my_select.class # not Enumerator
my_all?
- my_all? when no block or argument is given returns true when none of the collection members are false or nil
array = [1,2,5,4,7] p array.my_all? == array.all? # false - my_all? when a class is passed as an argument returns true if all of the collection is a member of such class
array = [1,2,5,4,7] p array.my_all?(Integer) == array.all?(Integer) # false - my_all? when a Regex is passed as an argument returns true if all of the collection matches the Regex
array = %w[dog door rod blade] p array.my_all?(/c/) == array.all?(/c/) # false - my_all? when a pattern other than Regex or a Class is given returns true if all of the collection matches the pattern
array = %w[dog door rod blade] p array.my_all?(5) == array.all?(5) # false
my_any?
- my_any? when no block or argument is given returns true if at least one of the collection is not false or nil
array = [1,2,5,4,7] p array.my_any? == array.any? # false - my_any? when a class is passed as an argument returns true if at least one of the collection is a member of such class
array = [1,2,5,4,7] p array.my_any?(Integer) == array.any?(Integer) # false - ( ] my_any? when a Regex is passed as an argument returns false if none of the collection matches the Regex
array = %w[dog door rod blade] p array.my_any?(/c/) == array.any?(/c/) # false - my_any? when a pattern other than Regex or a Class is given returns false if none of the collection matches the pattern
array = %w[dog door rod blade] p array.my_any?(5) == array.any?(5) # false
my_none?
- my_none? when no block or argument is given returns true only if none of the collection members is true
array = [1,2,5,4,7] p array.my_none? == array.none? # false - my_none? when a class is passed as an argument returns true if none of the collection is a member of such class
array = [1,2,5,4,7] p array.my_none?(Integer) == array.none?(Integer) # false - my_none? when a Regex is passed as an argument returns true only if none of the collection matches the Regex
array = %w[dog door rod blade] p array.my_none?(/c/) == array.none?(/c/) # false - my_none? when a pattern other than Regex or a Class is given returns true only if none of the collection matches the pattern
array = %w[dog door rod blade] p array.my_none?(5) == array.none?(5) # false
my_count
- my_count counts the number of items in enum that are equal to item if an argument is given
array = [7,8,9,5,1,0,2,4,0,1]
array.my_count(0) == array.count(0) # false- my_count counts the number of elements yielding a true value if a block is given
array = [1,2,8,9,7,5,6,3,11]
block = proc { |num| num < 5 }
array.my_count(&block) == array.count(&block) # falsemy_map
- my_map returns an Enumerator if no block is given
array = [1,5,8,7,9,5,5,55,5]
p array.my_map #error
LocalJumpError:
no block given (yield)
# ./Enumerable_Methods.rb:89:in `block in my_map'
# ./Enumerable_Methods.rb:12:in `my_each'
# ./Enumerable_Methods.rb:88:in `my_map'
my_inject
- my_inject combines all elements of enum by applying a binary operation, specified by a block
- my_inject when a symbol is specified combines each element of the collection by applying the symbol as a named method
array = [1,5,8,7,9,5,5,55,5] p array.my_inject(:+) # return this errors LocalJumpError: no block given (yield) # ./Enumerable_Methods.rb:100:in `block in my_inject' # ./Enumerable_Methods.rb:12:in `my_each' # ./Enumerable_Methods.rb:99:in `my_inject'
That's it ☺️ When finished, kindly resubmit another code review request 🙏
Happy coding ✌️
Ahmed Mahfoudh
There was a problem hiding this comment.
Status changes required
@KingsleyMcSimon great job so far there are just two more bugs 🐛 to take care of.
Also please take care of stickler problems.
Enumerable_Methods.rb
Outdated
| end | ||
|
|
||
| #my_inject method | ||
| def my_inject(param = nil, param1 = nil) |
There was a problem hiding this comment.
My inject
words = [] #=> some words
search = proc { |memo, word| memo.length > word.length ? memo : word }
words.my_inject(&search)) == words.inject(&search)
And
array.my_inject(:+) == eq array.inject(:+)
gives me this error
NoMethodError:
undefined method `length' for 5..50:Range
There was a problem hiding this comment.
Hi,
Please could you explain to me what you exactly mean by this review on this my inject method i have from this pull request: #3
whiz25
left a comment
There was a problem hiding this comment.
Hey @KingsleyMcSimon
Nice try implementing the suggested changes by the previous reviewer. However, this PR is not ready for merge yet.
See my comments and implement the requested changes.
Meanwhile, please fix the stickler error.
Martin Afani
|
|
|
This is really an old project and i believe that all the recommended changes has been implemented and the stickler and rubocop has passed its checks. |
Forison
left a comment
There was a problem hiding this comment.
Status:: Changes required❌
🙋♂️ McSimon !!!
Good job on addressing most of the issue raised in the earlier review, here are a few things we have to do to get this project approved.
- There should be a working
my_any?identical and returns the same thing as ruby'sany?. (Screenshot from Odin)
p [nil, true, 99].my_any?(Integer) should return same results as
p [nil, true, 99].any?(Integer)
- There should be a working
my_none?identical and returns the same thing as ruby'snone?. (Screenshot from Odin)
p [1, 3.14, 42].my_none?(Float) should return same result as
p [1, 3.14, 42].none?(Float)
- There should be working
my_injectidentical and returns the same thing as ruby'sinject. (Screenshot from Odin)
p (5..10).my_inject { |sum, n| sum + n } should be equal to
p (5..10).inject { |sum, n| sum + n }
p (5..10).my_inject(1) { |product, n| product * n } should be equal to
p (5..10).my_inject(1) { |product, n| product * n }
longest = %w{ cat sheep bear }.my_inject do |memo, word|
memo.length > word.length ? memo : word
end
p longest
should be equal to
longest = %w{ cat sheep bear }.inject do |memo, word|
memo.length > word.length ? memo : word
end
p longest
- Do not commit commented code in your file.
- Kindly remove your test examples for the main file, you can place your test examples in a separate file and import it as when needed.
Kindly make the changes and submit the project for a re-review😎.
Happy coding👨💻.
Addo Forison
|
@Forison. I have been able to implement the recommended changes on this PR but i think you may have to re-run these methods you asked me to work on: my_any?, my_none? and my_inject?. This is because it actually passes the required test. Thanks. |
Hi Simons, I tried to reach you on slack but It seems you are not available for now. I will record a loom video and attached to this file make you appreciate the persistent errors. |
There was a problem hiding this comment.
Status:: Changes required❌
🙋♂️ McSimon !!!
As I said in the comment I wanted to reach out to you via slack but you were not available, hence I have recorded a video to point the flaws to you.
- Click the link to view flaws as pointed out in my previous review. watch this video
Kindly reach out to me on slack if the video is not clear.
Kindly make the changes and submit the project for a re-review😎.
Happy coding👨💻.
Addo Forison
|
Hi TSE, |
Hi @KingsleyMcSimon . 👨🚀Good job trying to solve the problems listed above.However, we still have the same problems listed by the TSE above, Please make the changes required and submit for re-review once you are ready! Status: Changes required. ♻️[TSE: David Elí] |
|
I have actually worked on the recommended changes on the my_any?, my_none? and my_inject methods. |
|
Status: Changes Required ⚙️ #my_each
#my_each_with_index
#my_select
#my_all?
#my_any?
#my_none?
#my_count
#my_map
#my_inject
|
sumancrest0001
left a comment
There was a problem hiding this comment.
Please request another code review once you make the necessary changes.
if you need support or have a query regarding the review, message me on slack (Suman Shrestha)
Happy coding
|
Hi, good afternoon |
No description provided.