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

 

All ruby Questions

Ask your interview questions on ruby

Write Your comment or Questions if you want the answers on ruby from ruby Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---