Dear JD JD,

I'm not sure I got what you willing to accomplish.

But... try this.

"hello world".split.map(&:reverse).join(" ")

Step by step would be:

"hello world".split
 => ["hello", "world"]

"hello world".split.map { |word| word.reverse}
 => ["olleh", "dlrow"]

"hello world".split.map { |word| word.reverse}.join(" ")
 => "olleh dlrow"

Is it what you're looking for?

Best regards,
Abinoam Jr.

On Mon, Dec 16, 2013 at 11:47 PM, JD JD <lists / ruby-forum.com> wrote:
> Basically, I am working through some puzzles to learn ruby.  I just
> finished an online class learning this stuff, and want to test my
> knowledge.
>
> Basically, I am working through puzzles based off of "test driven
> development".
>
> I have basically been tested by making methods do things in the past
> puzzles.
>
> However, this current puzzle "puzzles" me in a way.
>
> Here is the test:
>
>  result = reverse do
>         "hello world"
>  end
>  result.should == "olleh dlrow"
> end
>
> It's basically rspec.  I understand what it is doing on some level.  Its
> basically taking in a string.  It's breaking down the string with
> probably a method .each.
>
> Most likely its implementing something like this
>
> (string).each do |word|
>     word.reverse
> end
>
> Problem is, I could make the above work if it was asking for me to make
> a method that takes in an argument.
>
> However, it's not asking for it to take in an argument.  So, I am
> completely lost.
>
> Can someone help me make sense of how to make this test pass?  How do I
> make this work?  I really am not familiar with this topic 100%.  I'm
> sure I learned about this, but if someone could help me in the right
> direction I would really appreciate it :).
>
> --
> Posted via http://www.ruby-forum.com/.