From: Rob Biedenharn Date: 2009-07-24T04:48:01+09:00 Subject: Re: Dir.entries, output showing nils On Jul 23, 2009, at 12:45 PM, Mmcolli00 Mom wrote: >> It should also be noted that you do not need to say [2..2] if you >> want >> the 3rd char of a string, just [2] >> will do. > > when I puts filename[2] it returns the 56, or 48 which I think is the > r's character id or maybe even index for that string. Not sure... In Ruby 1.8, String#[] with a single Integer argument returns the character, which as you've found is the ASCII code for the character. In Ruby 1.9, String#[] returns a 1-character string (and you can apply String#ord to it if you want the value) So filename[2..2] will give you a 1-character string in both versions. I'd stick with it. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com