Each_char

D

David Vlad

Hello

Im new to ruby and programming and I saw a guy do this on a tutorial
video:

"Hello".each_char do |x|
puts x
end

The result was that it printed one letter in the string at a time until
it had printed the whole word "Hello" in a vertical line. My problem is
that this wont work when I try it and I've done exactly like he did it.
The only thing I can think of is that maybe I have another version of
ruby than he has, but perhaps anyone of you knows the answer?
 
B

Brandon Jones

what version of ruby are you running? It works for me on 1.9.1 on
windows. Try this:
 
D

David Vlad

Brandon said:
what version of ruby are you running? It works for me on 1.9.1 on
windows. Try this:

Thanks, the example you made works (alto I didnt fully understand it).

Im about 95% sure that I am running ruby 1.8.6 since I just used the
one-click installer that's on ruby-lang.org. Why dont they have a
one-click installer for the latest version of ruby? XD
 
B

Brandon Jones

David said:
Thanks, the example you made works (alto I didnt fully understand it).

I think the 1.8x version of Ruby's string implementation is in another
module: jcode. I believe you can run your original code, you just have
to require 'jcode'.
Im about 95% sure that I am running ruby 1.8.6 since I just used the
one-click installer that's on ruby-lang.org. Why dont they have a
one-click installer for the latest version of ruby? XD

I don't know why they haven't packaged a more up-to-date one-click
installer. They do have the 1.9.1 version pre-built for windows. I'm
running it and it works great.
 
A

Aldric Giacomoni

Brandon said:
I don't know why they haven't packaged a more up-to-date one-click
installer. They do have the 1.9.1 version pre-built for windows. I'm
running it and it works great.

Because it's a lot of work :)
 
W

Walton Hoops

Because it's a lot of work :)
As I understand it, there will be no more 'one-click' installers. The
new 'official' windows installer is http://rubyinstaller.org/ which does
indeed have Ruby 1.9.1. A word to the wise, I'd suggest uninstalling
the old one-click, before installing the new rubyinstaller to avoid any
path confusions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top