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 trialJason Carr
5,495 PointsUsing the puts method, write anything to the file variable in the block.
I really can't understand what this task wants me to do!!
File.open("marto.txt", "a+") do |file|
end
2 Answers
Andrew Stelmach
12,583 PointsI've had a look at this and I think the following code should work, but it doesn't. I'm stumped! I'll have a look at the video later, maybe that will shed some light on it, but I really think this should work:
File.open("somefile.txt", "a+"){ |file| file.puts "Hello" }
(same as:)
File.open("somefile.txt", "a+") do |file|
file.puts "Hello"
end
Jason Seifer
Treehouse Guest TeacherAndrew Stelmach Jason Carr Sorry for the trouble! This code challenge was broken and has been fixed.
Andrew Stelmach
12,583 PointsThanks!
Andrew Stelmach
12,583 PointsAndrew Stelmach
12,583 PointsI used the Ruby docs, and also this for reference
Andrew Stelmach
12,583 PointsAndrew Stelmach
12,583 PointsJason Seifer this should work?