Hi, I’m doing a server and want to avoid memory innecesary operations.
I have an array of headers:
Each header is an object of “Header” class:
attr_accessor :name, :body
def initialize(name, body)
@name = name
@body = body
There are also others specific headers soons of “Header” class:
class From < Header
At the beggining “headers_array” just contain “Header” objects but
after inspection I want to replace the header with @name=‘From’ with a
“From” object but since “name” and “body” attributes are the same I
don’t want a memory copy operation to allocate space for new object.
This is: I just want to change the Class of a “Header” object to
“From” class, keeping the attributes without memory copy operation, is
there any way? I imagine in C I’d do it by using pointers.
Thanks for any help.