From: Tobias Reif Date: 2001-11-30T06:43:33+09:00 Subject: [ruby-talk:26970] Re: short article draft for review Jakub Travnik wrote: > this code is not good, it is too much boring ;-) Thanks a lot for you version! It is better. But the article is sent :( My version is perhaps simpler to understand (the article is for non-rubyists), and it demonstrates the nice case structure. > -8<--------------- > class String > NAMEMAP={'0'=>'zero', '1'=>'one', '2'=>'two', '3'=>'three', > '4'=>'four', '5'=>'five','6'=>'six', '7'=>'seven', > '8'=>'eight','9'=>'nine'} > def to_e > self.scan(/\d/).map{ |digit| NAMEMAP[digit]} > end > end > > > puts '24848567'.to_e > -8<--------------- -- Tobias Reif http://www.pinkjuice.com/myDigitalProfile.xhtml go_to('www.ruby-lang.org').get(ruby).play.create.have_fun http://www.pinkjuice.com/ruby/