Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Harish Ramachandran9,171 Points
Strings in Ruby
I'm learning about Strings in Ruby and I'm at the part where Jason talks about first_name pulling the ASCII value of the first letter of his name. I've tried this with my name and a few other variables in irb in my Mac Terminal but it seems to only return the actual value.
name = "Harish" puts name
In this case, name returns H but according to the video, it should return 72. I know I'm working with a newer version of Ruby than the one in the video - could this have anything to do with this? If not, did I do something wrong?
Justin HornerTreehouse Guest Teacher
I believe this is due to being on a newer version of Ruby. I'm running Ruby 2.0.0p451 and to accomplish this I used the .ord method like so.
name = "Jason" name.ord
I hope this helps.
Kang-Kyu Lee52,045 Points
or install ruby 1.8.7 and then irb :)
$ rbenv install -l $ rbenv install 1.8.7-p358