From: Justin Collins Date: 2007-10-10T10:24:44+09:00 Subject: Re: reading files smc smc wrote: > this is just a very basic example but how would you make it so that a user > may put their name (or some other info) into a file and then the program > reads it and sets it as a variable? > > so like: > > def say_hi(who) > result = "hello " + who > return result > end > > puts say_hi(person_name) > To read a file: person_name = File.read("somefile") To read from command line: person_name = gets.strip To make your say_hi shorter: def say_hi(who) "hello #{who}" end Hope that helps. -Justin