-
Notifications
You must be signed in to change notification settings - Fork 82
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
base: master
Are you sure you want to change the base?
Solution #84
Conversation
spec/refresher_spec.rb
Outdated
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] |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 😃
No description provided.