Reverse Ruby String Words

In my last post, i gave a simple snippet to reverse ruby string. Here, I am giving simple snippet to reverse ruby string words. So, given string like “ruby on rails”, the output going to be “rails on ruby”.


These icons link to social bookmarking sites where readers can share and discover new web pages.

  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • blinkbits
  • BlinkList

3 Comments »

  1. Piers Cawley said,

    May 8, 2007 @ 8:35 am

    There’s not much point in using reverse! on a temporary array.

    Personallly I lead towards a slightly more golfy:

    puts s.split(/(\s+)/).reverse.to_s

  2. admin said,

    May 8, 2007 @ 9:52 am

    Good point. Thanks for leaving comment!

  3. tramadol hydrocodone said,

    December 2, 2007 @ 10:46 am

    hydrocodone what erowid hydrocodone

RSS feed for comments on this post · TrackBack URI

Leave a Comment