Ryan Davis wrote in post #1094171:
> On Jan 28, 2013, at 10:01 , Joel Pearson <lists / ruby-forum.com> wrote:
>
>> def count_words(string)
>>  res = {}
>>  string.downcase!
>>  string.scan( /\w+/ ).uniq.each{ |word| res[word] =
>>    string.scan(/\b#{word}\b/).size }
>>  res
>> end
>
> This modifies the argument coming in. Don't ever call downcase! or other
> mutating methods on an argument or you'll wind up in debugging hell.
> Make a copy instead:
>
> string = string.downcase

Thanks, I thought that those two things were equivalent.
Doesn't string = string.downcase overwrite the argument string anyway?

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