Forum: Ruby Re: Getting last character from a string

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
397f61cc4458e13157b4facf72325e5f?d=identicon&s=25 Gennady Bystritsky (Guest)
on 2006-02-12 06:28
(Received via mailing list)
x[-1].chr

[tiger-ppc.gfbm:246]bystr> irb
irb(main):001:0> s = "abc"
=> "abc"
irb(main):002:0> s[-1]
=> 99
irb(main):003:0> s[-1].chr
=> "c"

irb(main):004:0>
This topic is locked and can not be replied to.