require question



Hello to the ruby-talkers. It's my first week with ruby, I'm reading Why's
poingnant guide currently. I'm not a programmer, my only knowledge is a
little php I use to do web stuff and some actionScript cus I do some Flash.
I thought of learning to program and Ruby is what I've chosen (even though
Eric Raymond says to learn Python is what he thinks is best). Anyways I
don't care, Why's poignant guide is funny as hell, and that's it. I wanna be
a part of it.

Now my question is (I'm assuming) a very simple one:

I'm trying to use the 'require' Kernel method.

I save a file as 'my_string.rb' and it contains just this:

my_string = 'hello world'

On another ruby file saved as 'my_string_reader.rb' I write:

require 'my_string'

puts 'my_string'

I thought that would output my 'hello world', but I get "undefined local
variable or method 'my_string' for main:Object (NameError)

I'm using windows xp. But the same problem happened on Ubuntu Linux. Same
error. It's the only example from Why's poignant guide that gives me errors
It's as if it's not reading the variables I've got stored in the required
file.

Thanks for your help.


--
-gaston


Relevant Pages

  • Re: *Fast* way to process large files line by line
    ... line and parse it. ... reading file loop> marshalling> parsing. ... the disk I am using is an LVM mapped ext3 local disk. ... Btw will using something like an mmap extension for ruby speed things ...
    (comp.lang.ruby)
  • Re: Ruby vs Java vs c++
    ... my feeling is that i hate BLOATED sluggish programs (like some Java ... speaking to one my programmer friends who is a top level Java ... such as Java or Ruby. ... truly appreciate a language like Ruby until you deal with a more... ...
    (comp.lang.ruby)
  • Re: A question about Intelligent Systems and using Ruby
    ... >Programming Ruby ) asking him about something ... >he had written in his preface. ... >reports/articles about Intelligent Systems programmed using in Ruby. ... >* Analyst Programmer and Developer ...
    (comp.lang.ruby)
  • Re: A question about Intelligent Systems and using Ruby
    ... for learning basic AI in ruby? ... > reports/articles about Intelligent Systems programmed using in Ruby. ... > am looking for Intelligent Systems specifically using Fuzzy Logic. ... > * Analyst Programmer and Developer ...
    (comp.lang.ruby)
  • Re: What Linux distribution to choose for learning Ruby and Ruby on Rails
    ... I am just another programmer whose ASP.NET career ... what Linux distribution would you recommend for programmer who have ... learning more Ruby and Ruby on Rails programming. ... playing around with system:) instaling packages in debian-based systems is much easier and faster. ...
    (comp.lang.ruby)