InterviewSolution
| 1. |
What is the use of load and require in Ruby ? |
|
Answer» In Ruby, load and require both are used for loading the available CODE into the current code. require` reads and parses files only once, when they were referenced for the FIRST time. `load` reads and parses files EVERY time you call `load`. require searches for the library in all the defined search paths and also appends .rb or .so to the file name you enter. It also makes SURE that a library is only included once. So if your application requires library A and B and library B requries library A too A would be loaded only once. With load you need to add the full name of the library and it gets loaded every time you call load - even if it already is in memory |
|