Notes to self
Showing posts with label ruby string. Show all posts
Showing posts with label ruby string. Show all posts
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'.
Subscribe to:
Comments (Atom)