Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJessica H
16,612 PointsBenchmarker Error
Why is the code not working and what am I missing here?
I want to add in the space between "elapsed" and the puts statement:
benchmarker = SimpleBenchMarker.new
but it does not recognize the variable at all.
I also tried adding above @benchmarker, attr_reader and a couple of other combinations and this isn"t working.
Idea?
class SimpleBenchmarker
def run(description, &block)
start_time = Time.now
block.call
end_time = Time.now
elapsed = end_time - start_time
puts "\n#{description} results"
puts "Elapsed time: #{elapsed} seconds"
end
end
4 Answers
William Li
Courses Plus Student 26,868 Pointsbenchmarker = SimpleBenchMarker.new
, there's typo here, it's SimpleBenchmarker, m in lowercase.
Jessica H
16,612 PointsThanks!
Jessica H
16,612 PointsSorry I tried it with lower case m and it is still not working.
((Bummer! The benchmarker
variable was not found.))
William Li
Courses Plus Student 26,868 Pointsbenchmarker = SimpleBenchmarker.new
not every letter in lower case.
Jessica H
16,612 PointsSomething is wrong with the form.
I did not use all lower case. I put "SimpleBenchmarker.new" I also copy/paste your answer there.
((Same error: Bummer! The benchmarker
variable was not found.))
Why is it not finding the new variable? I am trying to define it by call the new method on SimpleBenchmarker. Is something wrong with the website? Maybe a bug if it can not recognize what I'm doing...
I also already passed other challenges after this one. Only this challenge is stopping me from getting the badge.
William Li
Courses Plus Student 26,868 Pointsare you on part 1 of the challenge?
William Li
Courses Plus Student 26,868 Pointsclass SimpleBenchmarker
def run(description, &block)
start_time = Time.now
block.call
end_time = Time.now
elapsed = end_time - start_time
puts "\n#{description} results"
puts "Elapsed time: #{elapsed} seconds"
end
end
benchmarker = SimpleBenchmarker.new
Don't tell me copy/paste this entire code there don't get you pass the part 1.
William Li
Courses Plus Student 26,868 Pointsbtw, you should not change anything within class definition