String functions

I have string.
In that i need to display the first element from String means Which
Function Should I use?
I Am Unable To Figure Out…

Newb N. wrote:

I have string.
In that i need to display the first element from String means Which
Function Should I use?
I Am Unable To Figure Out…

If you mean first letter :

name[0] #shows code
name[0].chr #shows letter

On Thursday 21 August 2008, Newb N. wrote:

I have string.
In that i need to display the first element from String means Which
Function Should I use?
I Am Unable To Figure Out…

Try String#[] or String#slice, but since they return a number (the code
of the
first character) if you only specify an index, you’ll need to pass the
index
and a length of 1, like this:

“test string”[0,1]
=> “t”

For more information, see the documentation for the String#slice method
(ri
String#slice).

Stefano

Newb N. schrieb:

I have string.
In that i need to display the first element from String means Which
Function Should I use?
I Am Unable To Figure Out…

“ASDASDAS”[0] → 65

“ASDASDAS”[0].chr → “A”

Please add RDoc Documentation to your Favorites, look at
Class “String” and you will find everything you need.


Otto Software Partner GmbH

Jan P. (e-mail: [email protected])

Tel. 0351/49723202, Fax: 0351/49723119
01067 Dresden, Freiberger Straße 35 - AG Dresden, HRB 2475
Geschäftsführer: Burkhard Arrenberg, Heinz A. Bade, Jens Gruhl