Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
$filename = 'test.dat' [ '', 'a', 'aa' ].each do |data| # Write data File.open($filename, 'w') { |io| io.write(data) } # Read data File.open($filename, 'r') do |io| puts "Reading data..." until io.eof? data = io.read(1000) puts "Read data: #{data.inspect}" end puts "Done." puts end end # ===== ACTUAL OUTPUT # # Reading data... # Done. # # Reading data... # Read data: nil # Done. # # Reading data... # Read data: "aa" # Done. # # ===== EXPECTED OUTPUT # # Reading data... # Done. # # Reading data... # Read data: "a" # Done. # # Reading data... # Read data: "aa" # Done.
This paste will be private.
From the Design Piracy series on my blog: