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 trial

Ruby Ruby Core and Standard Library Ruby Core File

Using 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.rb
File.open("marto.txt", "a+")  do |file|

end

2 Answers

I'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

I used the Ruby docs, and also this for reference

Jason Seifer this should work?

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Andrew Stelmach Jason Carr Sorry for the trouble! This code challenge was broken and has been fixed.

Thanks!