I have a string that I need to get certain characters at a given index.
However, doing something like str[0] gives the ascii number, not the actual
character. How do I get it to give me the character?
···
--
Reese Chappuis
I have a string that I need to get certain characters at a given index.
However, doing something like str[0] gives the ascii number, not the actual
character. How do I get it to give me the character?
--
Reese Chappuis
I believe you're looking for the chr method
As in
string[0].chr
On Tue, Nov 8, 2011 at 10:53 AM, Reese Chappuis <c0dege3k@gmail.com> wrote:
I have a string that I need to get certain characters at a given index.
However, doing something like str[0] gives the ascii number, not the actual
character. How do I get it to give me the character?--
Reese Chappuis
Reese Chappuis wrote in post #1030886:
I have a string that I need to get certain characters at a given index.
However, doing something like str[0] gives the ascii number, not the
actual
character. How do I get it to give me the character?
str[0,1]
This is compatible with both ruby 1.8 and ruby 1.9.
--
Posted via http://www.ruby-forum.com/\.
I love this mailing list. I'm learning new things every day. Thank you Reese.
On Tue, Nov 8, 2011 at 12:02 PM, Brian Candler <b.candler@pobox.com> wrote:
Reese Chappuis wrote in post #1030886:
I have a string that I need to get certain characters at a given index.
However, doing something like str[0] gives the ascii number, not the
actual
character. How do I get it to give me the character?str[0,1]
This is compatible with both ruby 1.8 and ruby 1.9.
--
Posted via http://www.ruby-forum.com/\.