#reverse doesn't seem to work for me

Actually, I don't know if the method is the problem, but here's what I've
got....

a = 'stressed'
b = 'desserts'
a == b.reverse
=> true
words = File.open('american-english', 'r') {|f| f.read}.split.map {|w|
w.strip.downcase}
words.include? 'stressed'
=> true
words.include? 'desserts'
=> true
working = words.select {|w| w.length = 8}
working.include? 'stressed'
=> true
working.include? 'desserts'
=> true
palindrome = working.select {|w| w == w.reverse}
palindrome.empty?
=> true

It works for words of other lengths, though.

Maybe I'm misunderstanding what you're trying to do... but stressed and desserts aren't palindromes...

···

On May 1, 2014, at 11:10, Todd Benson <caduceass@gmail.com> wrote:

working = words.select {|w| w.length = 8}
working.include? 'stressed'
=> true
working.include? 'desserts'
=> true
palindrome = working.select {|w| w == w.reverse}
palindrome.empty?
=> true

'stressed' != 'desserts' so testing that w == w.reverse is working just
fine.

You probably want something like working.include?(w.reverse) although
that's an ugly concept that I'm sure someone would have a better answer for.

palindrome = working.select {|w| w == w.reverse}

John

You're right, it's not a palindrome. I feel like an idiot. I'd need to do
all the words for a comparison; in other words phrased, "Is there a word
out of the selection that is the reverse of my word." Yep, wasn't thinking.

···

On Thu, May 1, 2014 at 1:52 PM, Ryan Davis <ryand-ruby@zenspider.com> wrote:

On May 1, 2014, at 11:10, Todd Benson <caduceass@gmail.com> wrote:

> working = words.select {|w| w.length = 8}
> working.include? 'stressed'
> => true
> working.include? 'desserts'
> => true
> palindrome = working.select {|w| w == w.reverse}
> palindrome.empty?
> => true

Maybe I'm misunderstanding what you're trying to do... but stressed and
desserts aren't palindromes...