Skip to content

Instantly share code, notes, and snippets.

@nattybear
Last active January 22, 2021 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nattybear/f2b07069ce88ae889bcc24a9924b1ed1 to your computer and use it in GitHub Desktop.
Save nattybear/f2b07069ce88ae889bcc24a9924b1ed1 to your computer and use it in GitHub Desktop.

이 글은 Canol Gokel님이 만든 Computer Programming using GNU Smalltalk를 읽고 정리한 것이다.

Polymorphism

서로 다른 두 객체가 동일한 메세지에 같은 방식으로 대답을 할 수 있다.

그래서 어떤 언어에서는 서로 다른 클래스가 같은 이름의 셀렉터를 써서 메세지를 정의할 수 있다.

또는 subclass가 상속 받은 셀렉터의 기능을 변경할 수도 있다. overriding

이러한 것을 다형성 polymorphism이라고 한다.

예를 들어 Animal 클래스에는 speak라는 셀렉터가 있다고 할 때

Animal 클래스를 상속 받은 DogCat은 같은 speak라는 셀렉터를 만났을 때 서로 다른 방식으로 응답할 수 있다.

Computer Programming with GNU Smalltalk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment