M
Mikkel Kroman
Hello.
How can I be able to do something like this:
class Connection
attr_accessor :socket, :name
def initialize name
@name = name
end
def connect
@socket = TCPSocket.new
end
def saysomething
'phora'.say('hi!')
end
end
class String
def say message
@socket.puts("#{self} says #{message}")
end
end
conn = Connection.new "Mikkel"
conn.connect
conn.saysomething
String.socket = conn.socket # Something like this…
- Without having to use 'phora'.say('hi!', @socket)?
Sincerely,
Mikkel Kroman.
How can I be able to do something like this:
class Connection
attr_accessor :socket, :name
def initialize name
@name = name
end
def connect
@socket = TCPSocket.new
end
def saysomething
'phora'.say('hi!')
end
end
class String
def say message
@socket.puts("#{self} says #{message}")
end
end
conn = Connection.new "Mikkel"
conn.connect
conn.saysomething
String.socket = conn.socket # Something like this…
- Without having to use 'phora'.say('hi!', @socket)?
Sincerely,
Mikkel Kroman.