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

Solution #84

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

Solution #84

wants to merge 5 commits into from

Conversation

JeffMorhous
Copy link

No description provided.

expect(a_hash.empty?).to be true
end
end

context "on loops, yeah!!!" do
it "should loop over the array and return a new array" do
loopy = [1,2,3]
expect(loopy._fill_in_method_here_ { |n| n + 1 }).to eq [2,3,4]
expect(loopy.each { |n| n + 1 }).to eq [2,3,4]

Choose a reason for hiding this comment

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

Double check this one, I'm surprised it is passing. Notice the latter half of the string: and return a new array

Check out the differences between each and a method like map

  • What do they take?
  • What do they return?

Otherwise, nice work!

Copy link
Author

Choose a reason for hiding this comment

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

Good call! Looks like the each method lets us do something with each element of an array without actually changing it, like a for each, while returning the original array. Wheras map returns a new mutated array! And the test wasn't passing, but now it is 😃

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.

3 participants