Andreu wrote:
> Rob, thanks for your explanation. I feel more 'comfortable' now.
> The .join did the trick, although I'm not sure to
> completely understand it. (After all, I want to 'split'
> or 'remove' instead of 'join') but anyway it works.

Compare:

$ irb --simple-prompt
>> RUBY_VERSION
=> "1.8.6"
>> a = ["foo"]
=> ["foo"]
>> b = ["foo","bar"]
=> ["foo", "bar"]
>> puts a.to_s
foo
=> nil
>> puts b.to_s
foobar
=> nil
>> puts b.join(",")
foo,bar
=> nil

to:

$ irb19 --simple-prompt
>> RUBY_VERSION
=> "1.9.2"
>> a = ["foo"]
=> ["foo"]
>> b = ["foo","bar"]
=> ["foo", "bar"]
>> puts a.to_s
["foo"]
=> nil
>> puts b.to_s
["foo", "bar"]
=> nil
>> puts b.join(",")
foo,bar
=> nil

That is, ["TAB1"].to_s shows just 'tab1' in 1.8, but '["tab1"]' in 1.9. 
The data structure returned by execute is the same; it's what you're 
doing with it.

Since you know that tnam is an array with one element, I'd say that the 
simplest fix is

    name = tnam.first

However

    name = tnam.join

will achieve the same in a more obscure way, since you're taking the one 
string element, joining it (to nothing else) and getting the string.

Note also that "puts" special-cases arrays. "puts foo" is not the same 
as "puts foo.to_s" if foo is an array. (This is true for 1.8 as well as 
1.9)

>> puts a
foo
=> nil
>> puts b
foo
bar
=> nil
>> puts a.to_s
["foo"]
=> nil
>> puts b.to_s
["foo", "bar"]
=> nil
>> 

-- 
Posted via http://www.ruby-forum.com/.