Ruby/File Directory/file handle
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия) |
Текущая версия на 17:57, 13 сентября 2010
assign the file handle to a class or instance variable:
class MyFile attr_reader :handle def initialize(filename) @handle = File.new(filename, "r") end def finished @handle.close end end f = MyFile.new("text.txt") puts f.handle.gets f.finished