Append .cvs behind an array value


#1

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:ineach’
from test2.rb:39

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

thanks!


#2

On Sun, Apr 26, 2009 at 11:22 PM, Martin S. removed_email_address@domain.invalid
wrote:

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:ineach’
from test2.rb:39

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


#3

Martin S. wrote:

It’s an arry object.

…and how do you step through an array?


#4

It’s an arry object.

end

but error message is :

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

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


#5

arrayname.each do |name|
puts name

end

7stud – wrote:

Martin S. wrote:

It’s an arry object.

…and how do you step through an array?