Jari Williamsson wrote:
> John Wilger wrote:
>>> The disadvantage of making Array#to_csv is that you are
>>> modifying a global "variable" (the Array class).
>>
>> I'll take that disadvantage (in combination with good test coverage!)
>> over having to write verbose, type-checking code any day.
> 
> IMO, this is not an either/or case. Why not just add to_csv() only to 
> the instance who actually could need it?

How far in advance do you know that an instance needs this method?

If you wait too long, you end up with another case statement (again, on 
the class of the object, yuck) to decide which #to_csv is appropriate 
for the object.

If you add #to_csv eagerly, then the requirement that this object 
respond to #to_csv becomes a strong coupling between the point of 
creation and the #i_need_csv implementation.

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407