From: James Edward Gray II Date: 2006-02-12T09:12:35+09:00 Subject: Re: Getting last character from a string On Feb 11, 2006, at 6:07 PM, draco draco wrote: > Hello Hello. > I'm new to Ruby. Welcome then. > I've a simple question. > Is there a more readable way to get last character from string than > this > one? : > > x = "text" > last_char = x[x.length-1, x.length-1] Strings can take a negative index, which count backwards from the end of the String, and an length of how many characters you want (one in this example). Using that: "test"[-1, 1] # => "t" Hope that helps. James Edward Gray II