Most Ruby methods are named (in my eyes) logically and are sometimes abbreviations of their action. Numeric#divmod returns the div ision quotient and mod ulus, Numeric#fdiv stands for f loat div ision and they both make sense.
What does chomp in String#chomp mean, or what does it stand for?
It's an extension or play on the word "chop" (to cut). It also has a direct meaning:
chomp verb \ˈchämp, ˈchȯmp\
: to chew or bite on something
Source:
http://www.merriam-webster.com/dictionary/chomp
Ruby docs:
chomp(separator=$/) → new_str
Returns a new String with the given record separator removed from the end of str (if present). If $/ has not been changed from the default Ruby record separator, then chomp also removes carriage return characters (that is it will remove \n, \r, and \r\n).
So this method "chomps" or "chews" at the end of the string and removes it.
Hopefully that makes better sense now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With