Symbol
Last updated at 11:58 pm UTC on 15 October 2003
The class Symbol is a subclass of String. It represents unmutable strings, strings that are created uniquely. Symbols are identity objects. If two symbols are equal they are the same object.
Thus,
someString asSymbol == someString asSymbol.
The literal representation of Symbols are a sequence of characters preceded by a number sign (#; aka pound sign). See symbol literal.
#hello
Some common instance methods (Check the Class for more)
- accessing
- comparing
- testing
- isInfix, isKeyword, isLiteral, isPvtSelector, isUnary
- converting
- asString, asSymbol, capitalized
Common class methods
- Instance creation
- intern:, internCharacter:, lookup:
- accessing
- selectorsContaining: (e.g., Symbol selectorsContaining: 'at')
- thatStarts:skipping:
Example
Defining:
a := 'hello'.
b := 'hel', 'lo'.
evaluating
a = b
gives
true
evaluating
a == b
gives
false
evaluating
a asSymbol == b asSymbol
gives
true