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 trialDan Maliano
12,142 Pointsrespond with a string reading "Hello" followed by the contents of the name URL parameter.
What am I doing wrong here?
require "sinatra"
get "/greet/:name" do
puts "Hello #{params[:name]}"
end
1 Answer
Eric Butler
33,512 Pointsrequire "sinatra"
get "/greet/:name" do
"Hello" + params[:name]
end
Yours isn't quite right because you're using puts
instead of return
(or omitting both because Ruby implicitly "returns" whatever the last thing in a function is, as shown in my answer). Still, I think the answer-evaluator might be too finicky, because you should be able to do string interpolation like you did ("Hello #{params[:name]}"
) but when I did it it said it was wrong. I dunno.
Dan Maliano
12,142 PointsDan Maliano
12,142 PointsThank you very much Eric ;)