|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
RUBY
DETAILS
Question: What is the use of load and require in Ruby?
Answer: require 'rake'
will cause ruby to look for one of the files rake.rb or rake.so in the directories listed in $:. The script in bin is called simply rake, not rake.rb, and so require doesn't even consider it.
load, instead, interpret its argument in a different way: it considers it to be the whole basename of the file and doesn't try to add any extension to it. So, the line
load 'rake'
will make ruby look for a file called 'rake' (not rake.rb as before) in the directories listed in $:. This time bin/rake has the correct name and is loaded.
|
|
|
Category |
Ruby Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 7949 users |
Added on |
9/16/2014 |
Views |
69896 |
Rate it! |
|
|
Question:
What is the use of load and require in Ruby?
Answer:
require 'rake'
will cause ruby to look for one of the files rake.rb or rake.so in the directories listed in $:. The script in bin is called simply rake, not rake.rb, and so require doesn't even consider it.
load, instead, interpret its argument in a different way: it considers it to be the whole basename of the file and doesn't try to add any extension to it. So, the line
load 'rake'
will make ruby look for a file called 'rake' (not rake.rb as before) in the directories listed in $:. This time bin/rake has the correct name and is loaded. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What is the use of Destructive Method?
|
View Answer
|
|
What is the Notation used for denoting class variables in Ruby?
|
View Answer
|
|
What is the naming conventions for methods that return a boolean result?
|
View Answer
|
|
How do the following methods differ: @my_string.strip and @my_string.strip! ?
|
View Answer
|
|
How do you capitalize all characters in a string?
|
View Answer
|
|
What two delimiters are used for blocks?
|
View Answer
|
|
What’s the difference in scope for these two variables: @name and @@name?
|
View Answer
|
|
How do you write to STDOUT in Ruby?
|
View Answer
|
|
How do you comment out a block of code?
|
View Answer
|
|
Explain about ruby code blocks?
|
View Answer
|
|
Explain about interpolation?
|
View Answer
|
|
Explain about Float, Dig and Max?
|
View Answer
|
|
How does ruby deal with extremely large numbers?
|
View Answer
|
|
Explain about Class variable and global variable?
|
View Answer
|
|
Explain about variables?
|
View Answer
|
|
Explain about ruby names?
|
View Answer
|
|
Explain about normal method class?
|
View Answer
|
|
Explain about methods?
|
View Answer
|
|
Explain about the defined operator?
|
View Answer
|
|
Explain about operators in Ruby?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Ruby Interview Questions & Answers - Exam Mode /
Learning Mode
|