From: dblack@... Date: 2006-12-01T04:39:09+09:00 Subject: Re: simple question, looping through each character in a string Hi -- On Fri, 1 Dec 2006, James Edward Gray II wrote: > On Nov 30, 2006, at 1:13 PM, dblack@wobblini.net wrote: > >> You can also do: >> >> word.split(//).each {|char| puts char } > > Or without the Array: > > word.scan(/./m) { |char| ... } And, I now realize, if someone posted what I posted and I were responding to it, I would point out that: array.each {|e| puts e } is the same as: puts array Something I've described in the past as a nuby rite of passage, I believe... :-) > Or you can load the each_char() method from the standard library: > > require "jcode" > word.each_char { |char| ... } I don't think I've ever seen that one. So why is everyone so vexed about what's going to happen with this in 1.9? :-) (I know... it's not that simple.) David -- David A. Black | dblack@wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org