[squeak-dev] Re: How to copy method safely?

Matthew Fulmer tapplek at gmail.com
Mon Nov 3 04:29:46 UTC 2008


On Sun, Nov 02, 2008 at 10:10:49PM -0600, Sophie (itsme213) wrote:
> I have tried several combinations of poking around #methodDictionary, 
> #addSelector, even CompiledMethod>>#getSource fed to Compiler. I only 
> succeed in messing up things and getting a large red methods-list pane in my 
> browser window :-)
> 
> Any suggestions appreciated!
> 
> "itsme213" <itsme213 at hotmail.com> wrote in message 
> news:gekg54$l9a$1 at ger.gmane.org...
> >I have a class C1 with method M1 (source + compiled).
> >
> > How do I safely make a copy of M1 in another class C2 (same source + 
> > compile)?
> >
> > Thanks - Sophie

Well, the easiest way is to copy-paste.

I suppose some people here might recommend the Refactoring
Browser, but I don't trust that thing. I don't know of a
pre-built way to do it, but I think this will work:

To copy class1 >> selector into class2:

class2
    compile: (class1 sourceCodeAt: selector)
    classified: (class1 organization categoryOfElement: selector)

What are you trying to do?

-- 
Matthew Fulmer -- http://mtfulmer.wordpress.com/



More information about the Squeak-dev mailing list