From: Paul Lutus Date: 2006-11-30T02:45:22+09:00 Subject: Re: Need a range, but not getting it. . . . Peter Bailey wrote: > Jon Garvin wrote: >> Try... >> >> files = [ARGV].to_s >> files.gsub!(/\-/, "..") >> puts files >> >> However, I *think* that ARGV is already a string? so that to_s in the >> first line may be redundant. >> >> Your problem was that, although gsub! (with the !) normally modifies the >> receiver, 'files' wasn't the receiver (to_s was), so you weren't >> actually changing 'files'. > > Cool. That worked, Jon. Thanks. I don't quite understand it, though. I > suppose you're right, that gsub was modifying to_s and not files, but, > why was that? I thought that to_s was modifying files and then gsub was > modifying that modified files. I guess I need to tame my dots, eh? Some of the advice offered by Mr. Garvin was in error. Remember these points: 1. ARGV is an array. If you want to provide more than one input argument, you need to parse them: ARGV.each do |arg| # do something here end But you do not normally want to collapse the array into a single string using "ARGV.to_s" Mr. Garvin's remark about the receiver: >> Your problem was that, although gsub! (with the !) normally modifies the >> receiver, 'files' wasn't the receiver (to_s was), so you weren't >> actually changing 'files'. Is mistaken in this case. In fact, file.to_s.gsub!(...) will change the value of "files" if "files" is a string. In this case it is a string. -- Paul Lutus http://www.arachnoid.com