Archive for May 16th, 2008

ruby’s last character in a String

# returns the character code
# I don't know how to translate this back to a String
irb(main):002:0> "bar"[-1]
=> 114

# This works but reads a little awkward
irb(main):001:0> "bar"[-1..-1]
=> "r"