Skip to content

Completed Challenge#59

Open
trashcanmonster8 wants to merge 2 commits into
paircolumbus:masterfrom
trashcanmonster8:trashcanmonster-solution
Open

Completed Challenge#59
trashcanmonster8 wants to merge 2 commits into
paircolumbus:masterfrom
trashcanmonster8:trashcanmonster-solution

Conversation

@trashcanmonster8

Copy link
Copy Markdown

Needs grading but challenge completed.

Needs grading but challenge completed.
Comment thread spec/refresher_spec.rb
context "guess the type" do
it "Yes, it is a Object, but which" do
expect(:class.is_a? _fill_in_object_).to be true
expect(:class.is_a? Object).to be true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, it's an Object, but which....?

Comment thread spec/refresher_spec.rb Outdated
loopy = [1,2,3]
expect(loopy._fill_in_method_here_ { |n| n + 1 }).to eq [2,3,4]
loopy = [2,3,4]
expect(loopy.each { |n| n + 1 }).to eq [2,3,4]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That's cheating! :-) You can't change loopy; you need to find another method instead of each instead.

@trashcanmonster8

trashcanmonster8 commented Nov 30, 2016 via email

Copy link
Copy Markdown
Author

Changed method .each to .map! to properly make the changes needed to
loopy array. Returned loopy to the proper values.
Comment thread spec/refresher_spec.rb
loopy = [2,3,4]
expect(loopy.each { |n| n + 1 }).to eq [2,3,4]
loopy = [1,2,3]
expect(loopy.map! { |n| n + 1 }).to eq [2,3,4]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There you go! Er, except you don't want the ! in there. That will modify the array in place, as opposed to simply returning the desired array, which is all that is needed here. I'm not sure what your experience level is, but the general thinking is that, all else equal, it is better to avoid modifying objects in place.

@trashcanmonster8

trashcanmonster8 commented Nov 30, 2016 via email

Copy link
Copy Markdown
Author

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.

2 participants