Forum: Ruby Load vs Require

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hugo (Guest)
on 2006-01-28 12:02
Hello all!
Is there any difference between using Load and Require?
These two methods have the same performance?

Thank you for your answers.

Best regards,
Hugo
Eero Saynatkari (Guest)
on 2006-01-28 12:25
(Received via mailing list)
On 2006.01.28 20:02, Hugo wrote:
> Hello all!
> Is there any difference between using Load and Require?
> These two methods have the same performance?

#load always loads and interprets the file in question,
whereas #require will only do it the first time around
(filenames required earlier in $" or $LOADED_FEATURES).
This is very useful if you have a file that might change
while the program is running.

Here the two methods have distinctly different effects,
so efficiency should not really be a factor--just use
#load only when above behaviour is desired.

(And, in general, worry about performance only after
you have profiled your program and identified the
bottlenecks :)

> Thank you for your answers.
>
> Best regards,
> Hugo


E
This topic is locked and can not be replied to.