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
A way to do this for whitespace or non-whitespace characters is like this:
s = "\naaaa\nbbbb" s.slice!("\n") # returns "\n" but s also has the first newline removed. puts s # shows s has the first newline removed