Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.ruby Subject: Re: in `open': no implicit conversion of nil into String (TypeError) from ex30.rb:3:in `
' Date: Tue, 12 Apr 2016 08:09:59 +0200 Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net FOvUsTNblRj+Uk69LLEG2QspYyaDKUf6WB40h7s/z3xtZtchM= Cancel-Lock: sha1:rQggpzFv/S23+1vIPtfMAkWdTxY= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: Xref: csiph.com comp.lang.ruby:7211 On 12.04.2016 05:31, Cai Gengyang wrote: > This is my file which I saved as ex30.rb : > > filename = ARGV.first > > txt = open(filename) > > puts "Here's your file #{filename}:" > print txt.read > > print "Type the filename again: " > file_again = $stdin.gets.chomp > > txt_again = open(file_again) > > print txt_again.read > > This is the error I got when I tried to run it in my Terminal : > > CaiGengYangs-MacBook-Pro:GoatBoy CaiGengYang$ ruby ex30.rb > ex30.rb:3:in `open': no implicit conversion of nil into String (TypeError) > from ex30.rb:3:in `
' > > What's the error here ? Invoking the script without arguments. robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/