From: Ilan Berci Date: 2008-02-05T23:39:20+09:00 Subject: Re: got any good string exercises? Adam Akhtar wrote: > Looking for fairly simple string exercises that will familiarise myself > with all those string methods in the back of pickaxe. Dont want major > exercises like those in the ruby quiz as they demand knowledge in a lot > of other areas. > > Heres one example of the sort im looking for > > Rotate the words in a string around a fixed point given by a letter. Eg. > string = "Ruby is a great language" > puts Rotate(string, "a") > > output: "a great language ruby is" > > ok that one is probably at upper end of the scale when it comes to > difficulty but its quite focused. > > Anyone got any other string practice exercises that are short, > relatively simple and use some of the methods?? irb(main):002:0> "Ruby is a great language".reverse.split(" ").map {|w| w.reverse}.join " " => "language great a is Ruby" :) Best way is to just look at the string methods.. String.methods - Object.instance_methods hth helps -- Posted via http://www.ruby-forum.com/.