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 trialnathanielcusano
9,808 PointsHow do I get my program to work?
class Benchmarker
def run(&block)
present= Time.now
puts "This is the current time #{present}."
yield time
time
puts end_time - present
end
end_time= run do |time|
Time.now
end
end
benchmarker= Benchmarker.new
nathanielcusano
9,808 Pointsbench.rb:14:in <class:Benchmarker>': undefined method
run' for Benchmarker:Class (NoMethodError)
from bench.rb:1:in `<main>'
1 Answer
rowend rowend
2,926 PointsSet out of class the next code:
end_time= run do |time|
Time.now
end
And adjust to look like:
benchmarker= Benchmarker.new
end_time= benchmarker.run do |time|
Time.now
end
Brandon McClelland
4,645 PointsBrandon McClelland
4,645 PointsAre you getting an error message (please describe if so) or asking how to run it?