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: Wed, 13 Apr 2016 20:27:38 +0200 Lines: 33 Message-ID: References: <4d72edd3-6de5-433e-836e-56e297779e3a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net QOr9cfU3f31oeINiPGir8g/nLDWtheZidht1h6aDCcIs6AQKo= Cancel-Lock: sha1:YxGlTQvtNIgObm7xzzJJJ7tOlPc= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <4d72edd3-6de5-433e-836e-56e297779e3a@googlegroups.com> Xref: csiph.com comp.lang.ruby:7215 On 13.04.2016 18:08, Cai Gengyang wrote: > Ok, it works now ! I was on exercise 15 > (http://learnrubythehardway.org/book/ex15.html), not exercise 30 ... > just named it ex30 randomly because I previously saved another file > called ex15. That is still after exercise 13. > CaiGengYangs-MacBook-Pro:GoatBoy CaiGengYang$ ruby ex30.rb ex30_sample.txt > Here's your file ex30_sample.txt: > This is stuff I typed into a file. > It is really cool stuff. > Lots and lots of fun to have in here. > > Type the filename again: ex30_sample.txt > This is stuff I typed into a file. > It is really cool stuff. > Lots and lots of fun to have in here. > > I realised that I got the error because I initially forgot to create the 2nd sample.txt file That is wrong. You got the error because you did not pass an argument when invoking the script. You could also say that you got the error because your script did not deal well with invocation without arguments. Regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/