Loading other Plugin Files


I typically use this piece of code to load up other extension files:

	# Fix for ruby 2.0
	if this_dir.respond_to?(:force_encoding)

	# Read Dictionary Attributes


I am wondering if I should be checking to see if the file is already loading prior to actually loading it?

If a file has been already loaded and you load it again what are the implications if any?


The global array $LOADED_FEATURES, aka $" (that’s dollar sign + double quote) references an array of the pathnames of files already loaded.

Sketchp.load mimics Kernel.require, not Kernel.load (which will reload the file and does not check the $LOADED_FEATURES array.)

If a file has already been loaded then the 2 former methods return false. If it’s the first request to load a file and the file loads successfully, then true is returned.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.