From: Stefan Codrescu Date: 2009-03-07T07:57:49+09:00 Subject: Re: Setting the contents of a file to a variable? --00163646bfcc755b3504647b3c9c Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit ok, thanks ill try that but i also found file = File.open("guess.txt") $guess = file.gets which works for what im using it for. On Thu, Feb 26, 2009 at 7:38 PM, Justin Collins wrote: > Stefan Codrescu wrote: > >> Ok so... >> Ok... so I have file1 and it contains a number >> and I want file2 to tell me what that number is >> file2 would be something like >> >> class Tell >> def get_num(file = "file1.txt") >> num = contents of file1 >> $num = num >> end >> def tell_num >> puts "The number in file1 is #{$num}." >> end >> end >> >> What do I put instead of "contents of file1" >> Or some completely new code that does the same thing. >> >> >> > > File.read file > > > You probably also want $num to be @num instead (that is, an instance > variable rather than a global variable). > > -Justin > > -- There was a man, they called him mad. The more he gave, the more he had. --00163646bfcc755b3504647b3c9c--