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.
D3760253015655d7441a4206c762934d?d=identicon&s=25 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
5c7bdd14d6885c8275eaf78be41d120a?d=identicon&s=25 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.