Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #5043
| From | Robert Klemme <shortcutter@googlemail.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: String Element Reference |
| Date | 2011-05-25 19:29 +0200 |
| Message-ID | <944sjtFe5mU1@mid.individual.net> (permalink) |
| References | <f16342a93e87a7dafcd54bd5776d1c38@ruby-forum.com> |
On 25.05.2011 19:23, jason solomon wrote: > 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? > > Ideas / help would be greatly appreciated. This has changed in Ruby 1.9. You probably read 1.9 documentation that's why you expect a[0] to return "h". Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
String Element Reference jason solomon <solomon.jas@gmail.com> - 2011-05-25 12:23 -0500 Re: String Element Reference Robert Klemme <shortcutter@googlemail.com> - 2011-05-25 19:29 +0200 Re: String Element Reference jason solomon <solomon.jas@gmail.com> - 2011-05-25 12:34 -0500 Re: String Element Reference 7stud -- <bbxx789_05ss@yahoo.com> - 2011-05-25 12:40 -0500 Re: String Element Reference Javier Hidalgo Villegas <cooljavy@hotmail.com> - 2011-05-25 13:35 -0500
csiph-web