> Hi, to tackle such a question, I would use a combination of: > > * irb (or pry) > * ruby documentation (e.g. http://www.ruby-doc.org/core/Array.html) > * use the .class and .inspect method intensively to study what type and > content > the result of each intermediate step is > > So, in the session below, you see how I would build-up the result of your > excersize: > > peterv@ASUS:~$ ruby -v > ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux] > peterv@ASUS:~$ irb > 001:0> s = "foobar" > => "foobar" > 002:0> s.class > => String > 003:0> s.inspect > => "\"foobar\"" > 004:0> # now look up the documentation for String#split ( > http://www.ruby-doc.org/core-1.9.3/String.html) > 005:0* ^C > 005:0> s_split = s.split('') > => ["f", "o", "o", "b", "a", "r"] > 006:0> # now look up the documentation for Array#shuffle > 007:0* ^C > 007:0> s_split_shuffle = s_split.shuffle > => ["o", "o", "f", "r", "a", "b"] > 008:0> s_split_shuffle.class > => Array > 009:0> # now look up the documentation for Array#join > 010:0* ^C > 010:0> result = s_split_shuffle.join > => "oofrab" > 011:0> result.c
Thanks a lot mate. I was doing maximum right, but the way I was usaging the split and shuffle was wrong. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.