Rubyのメモ - 万年素人からHackerへの道

File.open("foo.txt", "r") do |io| while ! io.eof? print io.read(1) io.seek(1, IO::SEEK_END) # io.seek(1, IO::SEEK_CUR) # io.seek(1) io.seek(1, IO::SEEK_SET) # デフォルトなので上のなにもオプションがないのと同じ end end File.open("foo.txt", "r") do |io| puts io.gets # getsは1行読む。 puts io.read # r…