December 22, 2024

Answer to Collections Q6

 

ByteString

The add: message returns the argument and not the receiver. This is a classic Smalltalk "bug". You can avoid this by the use of the yourself message (found in Object), which returns the receiver.

deadPoets := Set new add: 'Milton';
                     add: 'Shakespeare';
                     add: 'Keats';
                     yourself

 

Back to « Collection Questions 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Up to top of page