-
Notifications
You must be signed in to change notification settings - Fork 15
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
Just Panda #9
base: master
Are you sure you want to change the base?
Just Panda #9
Conversation
def route | ||
CalculatesRoute.calculate(cities) | ||
def find_point(start_name) | ||
start = @cities.select {|city| city if city.name == start_name } |
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.
You can simplifiy this select to
start = @cities.select {|city| city.name == start_name }
The reason is that select works by keeping entries in the array where the block returns true. A simply example:
[1,4,5,6].select{|i| true}
=> [1,4,5,6]
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.
Further, since you are getting the first item, you can change to a find
def find_point(start_name)
@cities.find {|city| city.name == start_name }
end
This works where it early escapes after finding a true element
[2,3,3,3,4,5].find {|i| i.odd?}
=> 3
Excellent job! Especially nice job on the spec, with both should-equal and message expectations (should_receive). 👍 🎉 |
Hey Jesse, My code is a mess still. I can’t get benchmark to work…and my Rspec is all over the place. but I wanted to upload it…instead of just sitting on it and waiting for it to hatch.
|
@@ -1,7 +0,0 @@ | |||
Copyright (c) 2012 Jesse Wolgamott |
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.
Please leave the license files. (unless you plan to delete your repo)
Some promise here! The spec's don't pass though... want to take another run at the specs? |
I still haven't updated my spec. Thanks.