‹ BackHN Continuity

Thread

Ten lines of code that changed my world

148 points · 46 comments · dimonomid

  1. readthenotes1 · · focus · HN ↗
    Mine was

    someObject.changeToClassOf(SomrOtherClass);

    (or something like that--i'm was long ago).

    In Smalltalk, changing an object's class preserves instance variable (attribute) values when possible, silently dropping if not, and gives it an SomeOtherClass's inheritance (and method dictionaries as a result).

    It forced me to realize that an instance of a class wasn't permanently coupled to be an instance of the class that instantiated it or even its current class

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.