Skip to content

Instantly share code, notes, and snippets.

@nattybear
Last active January 17, 2021 13:43
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/e53dd3f850655bd647330ca2b7ebbaf5 to your computer and use it in GitHub Desktop.
Save nattybear/e53dd3f850655bd647330ca2b7ebbaf5 to your computer and use it in GitHub Desktop.

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

Message Cascading

객체 이름을 여러 번 쓰지 않고도 하나의 객체에 여러 메세지를 보낼 수 있는데 이런 기능을 메세지 캐스캐이딩 message cascading 이라고 한다.

형태는 아래와 같다.

objectName message1; message2; message3; ... ; messageN

보내고 싶은 메세지 사이에 세미콜론 ;을 적으면 된다.

아래와 같은 점이 메세지 체이닝과는 다르다.

  • 메세지 체이닝에는 세미콜론이 없다.
  • 메세지 체이닝은 앞의 메세지 결과에 메세지를 보낸다.

메세지 캐스캐이딩 예제는 아래와 같다.

Transcript show: 'Canol'; cr

cr은 캐리지 리턴 carriage return 이라고 부르는데 Transcript가 개행을 하게 된다.

Computer Programming with GNU Smalltalk

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