To get the last n
characters from a string, I assumed you could use
ending = string[-n..-1]
but if the string is less than n
letters long, you get nil
.
What workarounds are available?
Background: The strings are plain ASCII, and I have access to ruby 1.9.1, and I'm using plain old ruby objects (no web frameworks).