2010/2/8 Mikkel Kroman <mk / maero.dk>:
> How can I be able to do something like this:
>
> class Connection
>  ¨Βττςίαγγεσσος Ίσογλετ¬ Ίξαν>
>  ¨Βεζ ιξιτιαμιϊε ξανε
>  ¨Βξανε ξανε
>  ¨Βξδ
>
>  ¨Βεζ γοξξεγ>  ¨Βσογλετ ΤΓΠΣογλετ®ξε>  ¨Βξδ
>
>  ¨Βεζ σαωσονετθιξη
> phora'.say('hi!')
>  ¨Βξδ
> end
>
> class String
>  ¨Βεζ σανεσσαη>  ¨Βσογλετ®πυτσ¨Ά£ϋσεμζύ σαωσ £ϋνεσσαηεύΆ©
>  ¨Βξδ
> end
>
> conn = Connection.new "Mikkel"
> conn.connect
> conn.saysomething
>
> String.socket = conn.socket # Something like this>
> - Without having to use 'phora'.say('hi!', @socket)?

Frankly, you do not want to be doing this.  First of all String's
capabilities aren't really in the area of socket communication.  Class
String is responsible for manipulating strings in various ways but not
for doing IO.

Then, making possible what you want to do will make your code hard to
impossible to read because you have *implicit* transfer of
information.  These things are hard to understand and consequently
hard to use and debug.

Since you do have your simple abstraction already (method
Connection#saysomething) you should stick with that.  Btw, I would add
at least one parameter to #saysomething, namely the thing you want to
say.

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/