My program is split up into multiple files, each containing a set of
related class definitions. In the main file, all these files are
included by using require. But how can i avoid multiple inclusion of a
file by mistake.
Is there anything similar to C languages #ifndef …
This will work fine. You will run into problems if you put relative
Either use full paths, or add directories to the $LOAD_PATH to protect
file by mistake.
twice and I had to spend a lot of time to figure out how this
happened. So thats why my question, how can I avoid multiple inclusion
of files.
suresh
I just told you how to avoid it. If you’re getting collisions, then
you’re doing what I’ve outlined above.
Is there anything similar to C languages #ifndef …
thanks
suresh
Hi Jason,
Will tell you what happened to me. I had some database populating code
in some import class definitions. By mistake that file got included
twice and I had to spend a lot of time to figure out how this
happened. So thats why my question, how can I avoid multiple inclusion
of files.
Will tell you what happened to me. I had some database populating code
in some import class definitions. By mistake that file got included
twice and I had to spend a lot of time to figure out how this
happened. So thats why my question, how can I avoid multiple inclusion
of files.
suresh
if you are writing the files that are included you can self-protect them
unlss defined? $mylib
module MyLib
end
end
however, if you expect something like rails or ramaze to autoload
these files in development mode think twice.