Simple =)

s = "1234567890"
r=String.new
i = 1; while i <= s.length
  r << s[-i]
  i+=1
end

r == s.reverse
true

r is now the  reverse of s

On Thu, Apr 21, 2011 at 10:54 PM, Rubist Rohit
<passionate_programmer / hotmail.com> wrote:
> I am trying this:
>
> mystring = gets
> mystring.scan(/..$/) {|x| puts x}
>
> It returns only the last character. Is it possible to add the above line
> in loop?
>
> --
> Posted via http://www.ruby-forum.com/.
>
>