< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous artilce (have the same parent)
N :the next (in thread)
|<:the top of this thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
This was the solution I came up with, and it appears to have made it
work:
def reverse
sentence=yield.split
sentence.map do |word|
word.reverse!
end
sentence.join(" ")
end
Basically, from my understanding yield is split and made into an array
and put into sentence. Then sentence uses map to iterate over each
element in the array and .reverse! is used to reverse each element. I
used reverse! instead of reverse (without the ! point) to keep the
change permanent. Playing around with it in irb it showed that it would
just change back without the !.
Then I used .join(" ") to turn the array into a string and join the
words with a space.
However, I am still semi lost. I don't understand the difference
between .map and .each. All I know is using .each doesn't seem to make
the thing pass. Could someone explain me the difference between the
two?
Also, I am still really confused about this. You are correct, tamouse
m, this was to introduce blocks. However, this set up really confuses
me. How does yield take in the "hello world"? I find it really
confusing. Could someone explain this set up a little more? It appears
it is blocks, but I am used to using blocks in a different context and I
find this set up/thing really confusing.
PS: To the last poster, I got these puzzles a while ago. I don't know
where they are from though or how to get them now (again, got them a
while back). They have some out there on the the net though I'm sure.
Various sites seem to provide them without even having to download them
if you search around. I'm sure someone knows a good site, but I'm not
familiar with the best site to use really. Sorry I'm not being very
helpful here I guess.
--
Posted via http://www.ruby-forum.com/.