목 ¶
- SBPP를 부 문 떼는 들.
본 문 ¶
~cpp ClassName>>methodName.
- 는 문 . 만, Smalltlak 명 메 디 는를 만들 .
- Debug 모 메 낼 .
- 는 문 . 만, Smalltlak 명 메 디 는를 만들 .
~cpp 배 보는 러 메 UndifinedObject(Object)>>doesNotUnderstand:
~cpp a := 1. b := OrderedCollection new.
~cpp Money class>>amout: anAmount self new setAmount: anAmount.
~cpp TempTestCase>>initialize super initialize.
~cpp a := OrderdCollection new add: 10; add: 1; add; 9; yourself.
~cpp Color>>alpha ... ^1.0
메 보내 ¶
from VisualWorks Lesson Browser 01 (Lesson: Language Basic)
- 모 몰 따른.All Smalltalk expressions follow the form:
- anObject aMessage.
- )
~cpp "Code in Bold" "Comments in double-quotes" 3 squared. "Receiver object is small integer 3." "The message sent is #squared" 'abc' asUppercase. "Receiver object is string 'abc'." "The message sent is #asUppercase" 200 factorial. "Receiver object is small integer 200." "The message sent is #factorial"
메 ¶
from VisualWorks Lesson Browser 01 (Lesson: Language Basic)
- Unary messages
- 는 며, 는 .(the selector is a single Identifier, there are no arguments)
- )
~cpp 3 negated "selector is #negated" 'abcdefg' reverse "selector is #reverse"
- 는 며, 는 .(the selector is a single Identifier, there are no arguments)
- Binary messages
- 는 ( 문, ), 딱 만 .(the selector is one or two non-alphanumeric characters, followed by exactly one argument object)
- )
~cpp 3 + 5 "selector is #+" "argument is the Integer object 5" 'abc' , 'xyz' "selector is #, (comma character)" "argument is the String 'xyz'" 20 <= 20 "selector is #<=" "argument is the Integer object 20"
- 는 ( 문, ), 딱 만 .(the selector is one or two non-alphanumeric characters, followed by exactly one argument object)
- Keyword messages
- 란 (:) 뒤 붙는 .(a keyword is an Identifier followed by colon ":" )
- , 는 .(the selector is one or more keywords, when called each keyword is followed by an argument object) -> 번
- )
~cpp 3 raisedTo: 17. "selector is #raisedTo:" "argument is 17" 3 between: 5 and: 10. "selector is #between:and:" "arguments are 5 and 10" Point x: 4 y: 200. "receiver is the object Point" "selector is #x:y" "arguments are 4 and 200"
- 란 (:) 뒤 붙는 .(a keyword is an Identifier followed by colon ":" )
¶
2 + 3 * 6 몇?
Message ¶
from Smalltalk by Example
- 메는 른 . Evaluation is done left to right.
- 2 + 3 * 6 -> 30
- 2 + 3 * 6 -> 30
- Unary 메는 높 를 . messages have the highest precedence.
- Binary 메는 를 . Binary message have the next precedence.
- Keyword 메는 낮 를 .Keyword message have the lowest precedence.
- '()' 를 를 변 . You can alter precedence by using parenthses.
Smalltalk