Anonymous user
GNU Smalltalk: Difference between revisions
→Examples: Changed wiki italics back to single quotes
m (Use the implementation template, removed link to "hello world") |
(→Examples: Changed wiki italics back to single quotes) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 10:
Some basic Smalltalk code:
===Collections===
Line 115 ⟶ 116:
===Classes===
The following code defines a class named Person. By deriving from Magnitude, it automatically defines all comparison methods except one (<
Magnitude subclass: Person [
Line 144 ⟶ 145:
===Exceptions===
An exception is raised with a <
self halt
An optional message can be added to the exception; there's also <
self halt: 'This is a message'
self error: 'This is a message'
These are actually wrappers for the actual exception raising method, <
Error signal
|