In Ruby, sometimes I need to remove the new line character at the beginning of a string. Currently what I did is like the following. I want to know the best way to do this. Than
To be perfectly accurate chomp not only can delete whitespace, from the end of a string, but can also delete arbitrary characters.
chomp
If the latter functionality is sought, one can use:
'\naaaa\nbbbb'.delete_prefix( "\n" )
But now you this works for arbitrary characters exactly like chomp.