|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
RUBY
DETAILS
Question: What is the use of Destructive Method?
Answer: In ruby, we conventionally attach '!' or '?' to the end of certain method names. The exclamation point (!, sometimes pronounced aloud as "bang!") indicates something potentially destructive, that is to say, something that can change the value of what it touches. chop! affects a string directly, but chop with no exclamation point works on a copy. Here is an illustration of the difference. s1 = "forth" s1.chop! s2=s1.chop
|
|
|
Category |
Ruby Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 6978 users |
Added on |
9/16/2014 |
Views |
65569 |
Rate it! |
|
|
Question:
What is the use of Destructive Method?
Answer:
In ruby, we conventionally attach '!' or '?' to the end of certain method names. The exclamation point (!, sometimes pronounced aloud as "bang!") indicates something potentially destructive, that is to say, something that can change the value of what it touches. chop! affects a string directly, but chop with no exclamation point works on a copy. Here is an illustration of the difference. s1 = "forth" s1.chop! s2=s1.chop 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 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
|
|
Explain about environment variables present 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
|