You can move a method from one instance to another within th

You can take a method from one instance and move it to another instance

me = cls.method(:mymthd) <== get hold of the method
unbnd = me.unbind <== unbind it from the class
newinst = <== create instance of a subclass of cls
unbnd.bind(newinst).call <== bind the method to the instance of

I know it isn’t copying it but is shows the mobility of unbound
methods. Not sure if you can copy it while it is an unbound method?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs