Ruby: How to get the first character of a string

Posted by Shpigford on Stack Overflow See other posts from Stack Overflow or by Shpigford
Published on 2010-04-28T15:25:12Z Indexed on 2010/04/28 15:43 UTC
Read the original article Hit count: 244

Filed under:
|
|

How can I get the first character in a string using Ruby?

Ultimately what I'm doing is taking someone's last name and just creating an initial out of it.

So if the string was "Smith" I just want "S".

© Stack Overflow or respective owner

Related posts about ruby

Related posts about string