[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how to use it: require

Servando Garcia

3/5/2006 3:25:00 PM

I have a custom file filled with a word list. How do call it in my main
program.
I have tried "require wordlist" but ruby can't find the file
In C/C++ I would have used Include<wordlist.h> or for python I would
have used "import wordlist" so long as the wordlist was placed in the
same directory I am good. So how do I do this using ruby



Before I forget I want to thank everyone for their help. I am really
liking Ruby and I finally understand how to use symbols



Sam Garcia


2 Answers

Diego Cano Lagneaux

3/5/2006 3:36:00 PM

0


> I have a custom file filled with a word list. How do call it in my main
> program.
> I have tried "require wordlist" but ruby can't find the file
> In C/C++ I would have used Include<wordlist.h> or for python I would
> have used "import wordlist" so long as the wordlist was placed in the
> same directory I am good. So how do I do this using ruby
>
Call the file wordlist.rb, then require it like this:

require "wordlist"

elKano


james_b

3/5/2006 3:36:00 PM

0

Servando Garcia wrote:
> I have a custom file filled with a word list. How do call it in my main
> program.
> I have tried "require wordlist" but ruby can't find the file
> In C/C++ I would have used Include<wordlist.h> or for python I would
> have used "import wordlist" so long as the wordlist was placed in the
> same directory I am good. So how do I do this using ruby
>

require is a method call that takes a string.


require 'wordlist'

'wordlist' needs to be in some directory that is part of the Ruby
interpreter's current load path.

http://www.ru.../core/classes/Kernel.ht...


>
>
> Before I forget I want to thank everyone for their help. I am really
> liking Ruby and I finally understand how to use symbols


Great! Now learn to abuse them!




--
James Britt

http://www.ru... - Ruby Help & Documentation
http://www.artima.c... - The Journal By & For Rubyists
http://www.rub... - The Ruby Store for Ruby Stuff
http://www.30seco... - Building Better Tools