Monday, February 25, 2008

String: extract a single character

Whenever I wanted to extract a single character from a string, invariably I started with something like "hello"[1] and Ruby returns 104. That's the ascii code for 'h'. Its not at all useful. I should practice saying "hello"[0,1] which will return what I want, i.e. 'h'.

No comments: