Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr-8 #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Pr-8 #9

wants to merge 2 commits into from

Conversation

CheezItMan
Copy link

No description provided.


array.each do |element|
flattened_array = self.add_element_array(element, flattened_array)
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to add a new line here.

Suggested change
end
end

end

def self.add_element_array(element, array)
# binding.pry

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment?

else
array << element
end
array

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An explicit return might make this more legible.

Suggested change
array
return array

end
end

module BookKeeping

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might just be me, but it's a little hard to understand what this is doing. Could you maybe add a comment for context?

end

def self.add_element_array(element, array)
# binding.pry

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# binding.pry

Consider removing this line if we are wanting to push to prod.

def self.flatten(array)
flattened_array = []

array.each do |element|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a .map instead of .each. This would not require declaring var in line 5.


module BookKeeping
VERSION = 1 # Where the version number matches the one in the test.
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

else
array << element
end
array

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

including return would be helpful

array.each do |element|
flattened_array = self.add_element_array(element, flattened_array)
end
flattened_array.compact

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compact returns a copy of the array which increases space complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants