append .cvs behind an array value

M

Martin Sharon

I want to add ".cvs" at the end of a name,and use the following
sentenses:


namelist.each do |name|
name = name +'.cvs'
end

but error message is :

test2.rb:43:in `+': can't convert String into Array (TypeError)
from test2.rb:43
from test2.rb:39:in `each'
from test2.rb:39

What's wrong with it? how to fix it?

thanks!
 
T

Todd Benson

I want to add ".cvs" at the end of a name,and use the following
sentenses:


namelist.each do |name|

puts name.class
#this will tell you what your name objects are
name = name +'.cvs'
end

but error message is :

test2.rb:43:in `+': can't convert String into Array (TypeError)
from test2.rb:43
from test2.rb:39:in `each'
from test2.rb:39


If your objects in namelist are enumerable objects, then you must
further take it apart.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top