Completed Challenge#59
Open
trashcanmonster8 wants to merge 2 commits into
Open
Conversation
Needs grading but challenge completed.
sjreich
reviewed
Nov 30, 2016
| 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 |
sjreich
reviewed
Nov 30, 2016
| 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] |
There was a problem hiding this comment.
That's cheating! :-) You can't change loopy; you need to find another method instead of each instead.
Author
|
Oops forgot to change that back... Thanks for the feedback!
Question if you don't mind me asking: Shouldn't I use loopy.each there? I
tried that first and it still failed the test. And currently my code should
return [3, 4, 5], correct? Yet it does pass the test. What am I missing?
Thank you for your time,
Jake Mayer
…On Nov 29, 2016 10:31 PM, "Joe Reich" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In spec/refresher_spec.rb
<#59 (review)>
:
> 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]
+ loopy = [2,3,4]
+ expect(loopy.each { |n| n + 1 }).to eq [2,3,4]
That's cheating! :-) You can't change loopy; you need to find another
method instead of each instead.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#59 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVuix233l-ZLnZpvv_agAqZ5RIMUwiKgks5rDO3zgaJpZM4K_wfY>
.
|
Changed method .each to .map! to properly make the changes needed to loopy array. Returned loopy to the proper values.
sjreich
reviewed
Nov 30, 2016
| 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] |
There was a problem hiding this comment.
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.
Author
|
Thanks for the feedback. Until recently I programmed as a hobby (in C#),
but now I have been offered a job testing in Ruby. So I need to get my
bearings in this language.
That makes sense to keep data unchanged if possible. I wasn't sure if the
test was looking at loopy itself or the output of the method. Thanks again
for the feedback!
…-Jake
-Jake
Jacob Mayer | Math Nerd | Problem Solver | Self-Starter
[image: Open ...] <https://www.linkedin.com/in/jacobmayer>[image: Original
...] <jacob.michael.mayer@gmail.com>[image: File:Small-Blue-Logotype.png]
<http://jake-in-development.weebly.com/>
On Wed, Nov 30, 2016 at 9:41 AM, Joe Reich ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In spec/refresher_spec.rb
<#59 (review)>
:
> @@ -75,8 +75,8 @@
context "on loops, yeah!!!" do
it "should loop over the array and return a new array" do
- 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]
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#59 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVuix85eFvaZPTtumj6T3PkV9HLnDiSPks5rDYsAgaJpZM4K_wfY>
.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Needs grading but challenge completed.