J
Josh Charles
I've been working on this piece of code and it's starting to drive me
crazy. I think it's a problem with reference vs value type, but I'm
not sure. I'm just writing a simple program to process a list of
words and print out all the palindromes (words that read the same
forward and backward)
Here is my code:
file =3D File.open("testdict.txt", "r" ) do |file|
file.each_line("\n") do |line|
#filelist.push( line )
line.downcase!
if (line =3D=3D line.reverse)
puts line
end
end
end
I've made sure each line is being read properly, and it is. The if
statement never returns true, however. I'm new to ruby, so I'm
probably just doing something really stupid, but I can't figure it out
yet.
Josh
crazy. I think it's a problem with reference vs value type, but I'm
not sure. I'm just writing a simple program to process a list of
words and print out all the palindromes (words that read the same
forward and backward)
Here is my code:
file =3D File.open("testdict.txt", "r" ) do |file|
file.each_line("\n") do |line|
#filelist.push( line )
line.downcase!
if (line =3D=3D line.reverse)
puts line
end
end
end
I've made sure each line is being read properly, and it is. The if
statement never returns true, however. I'm new to ruby, so I'm
probably just doing something really stupid, but I can't figure it out
yet.
Josh