Main Content
puts - opposite of chomp in Ruby Archive - Originally posted on "The Horse's Mouth" - 2006-12-15 04:56:03 - Graham Ellis
In Ruby, the chomp method removes the last character of a string if it's a line separator. The puts method adds a new line character on to the output unless there's one already present.
In Perl and other languages, a great deal of time and mental agility is expended in remembering where there are (and where there are not) end of line characters, and this practical ("pragmatic") approach in Ruby really makes life easy.
Some other articles
R109 - Strings and Regular Expressions Clarrissa-Marybelle - too long to really fit? Regular Expressions for the petrified - in Ruby Global Regular Expression matching in Ruby (using scan) Ruby - standard operators are overloaded. Perl - they are not Ruby - a teaching example showing many of the language features in short but useful program Matching regular expressions, and substitutions, in Ruby Divide 10000 by 17. Do you get 588.235294117647, 588.24 or 588? - Ruby and PHP Ruby - examples of regular expressions, inheritance and polymorphism Object Oriented Ruby - new examples Ruby collections and strings - some new examples Neatly formatting results into a table Search and replace in Ruby - Ruby Regular Expressions The dog is not in trouble Regular Expressions in Ruby Ruby to access web services Ruby Programming Course - Saturday and Sunday What are exceptions - Python based answer String interpretation in Ruby Regular expressions made easy - building from components Regular Express Primer Ruby v Perl - interpollating variables This article String duplication - x in Perl, * in Python and Ruby R103 - Basic Ruby Language Elements Where does Ruby load modules from, and how to load from current directory Ruby - the second rung of learning the language Learning to program - variables and constants BODMAS - the order a computer evaluates arithmetic expressions Ruby - standard operators are overloaded. Perl - they are not Sigils - the characters on the start of variable names in Perl, Ruby and Fortran Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. Comparing floating point numbers - a word of caution and a solution Constants in Ruby Variable scope - what is it, and how does it Ruby? Learning to program in Ruby - examples of the programming basics This article