jason solomon wrote in post #1000974: > I am new to Ruby so I apologize if this seems dumb. > > I am currently running ruby 1.8.7 (2009-06-12 patchlevel 174) > [universal-darwin10.0]. > > When working in an irb session I'm having trouble with String element > reference. > > Example: > > a = "hello" > > a[0] should return "h", but instead is returning 104. > > Seems like it's return the ascii value of the element, but why? > > > When I do a[0,3] the return is the expected "hel". > > > > > Any ideas as to why a[0] is returning a FixNumb object? > For some reason Matz thought it was more useful to define the [] method for strings to return the ascii value. As you discovered, if you specify a length as the second argument, you get the characters. Applying that knowledge, if you specify a length of 1, you will get the character. So the expression: str[0,1] will return the character in both ruby 1.8 and ruby 1.9. -- Posted via http://www.ruby-forum.com/.