From: "Decurnex Gorosito, Roberto Eduardo" Date: 2007-12-23T02:56:02+09:00 Subject: Re: no method error (because of unknown variable type) Hi Haris, the problem here is that the eof or the eof? methods must be used with files open as readeble like file_1( 'bla.txt', 'w' ). If you are writing a file the eof is noy defined cuz you are always adding data to the end of it. The evaluation of the object class is made on the fly, ruby doesn't try to predict the future objects classes. Eduardo, Gorosito Haris Bogdanovic wrote: > Hi ! > > Here is a little example: > > file "Functions.rb": > #--------------------- > def func(file) > if !file.eof then #do something. > end > #--------------- > > file "main.rb": > > require 'Functions' > file_1=open('bla.txt','w') > func(file_1) > file_1.close > > I get an error message that eof method is undefined. > I presume that this is because ruby does not know that the "file" variable > is going to become a File.object. > How do I solve this ? > > Thanks. > > > > >