Each_char

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?

···

--
Posted via http://www.ruby-forum.com/.

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

···

"Hello".each_byte { |x| puts x.chr }

--
Posted via http://www.ruby-forum.com/\.

Brandon Jones wrote:

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

"Hello".each_byte { |x| puts x.chr }

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

···

--
Posted via http://www.ruby-forum.com/\.

David Vlad wrote:

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.

···

--
Posted via http://www.ruby-forum.com/\.

Brandon Jones wrote:

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 :slight_smile:

···

--
Posted via http://www.ruby-forum.com/\.

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.

···

On 3/11/2010 1:39 PM, Aldric Giacomoni wrote:

Brandon Jones wrote:
  

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 :slight_smile: