Hi Yochen,

Yochen Gutmann wrote:
> class SomeMonsterousClass
> 
>    def very_complexe_method a_very_complicated_obejct
>      a_very_complicated_obejct.do_something
>      lots_of_other_operations
>      lots_of_other_operations
>      lots_of_other_operations
>      lots_of_other_operations
>       ...
>    end
> end
> 
> So here you cant just convert any given object to 
> a_very_complicated_object. 

Why not? I usually do this:

   class ComplicatedObject
     def to_complicated_object
       self
     end
   end

 > By the way your solution would not work with
> nil.

Why not? It would complain that nil doesn't respond to #to_str. You 
could expand it to this:

   def foo(obj)
     unless obj.respond_to? :to_str
       raise ArgumentError, "argument must be a string"
     end

     str = obj.to_str

     ...
   end


Cheers,
Daniel