From: Haris Bogdanovic Date: 2007-12-23T04:05:05+09:00 Subject: Re: no method error (because of unknown variable type) Problem solved ! It's because the file was opened as 'w' and not 'r'. I firstly created file and put some data into it and then I forgot to close it and reopen it as 'r'. It was strange to me that ruby would check for variable types in that way but obviously I was assuming wrong. Thanks. "Haris Bogdanovic" wrote in message news:fkjhnd$c6f$1@garrison.globalnet.hr... > 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. >