Changes between Version 13 and Version 14 of squeak_faq_new
- Timestamp:
- 03/25/2015 11:36:11 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
squeak_faq_new
v13 v14 34 34 35 35 === How do I leave a method without returning a value, e.g. early return? === 36 In !Smalltalk `^` behaves similar to return in other languages. If a method in !Smalltalk should return nothing, typically you return `self`. You should avoid to return `nil`.36 In Smalltalk `^` behaves similar to return in other languages. If a method in Smalltalk should return nothing, typically you return `self`. You should avoid to return `nil`. 37 37 38 38 === How do I break inside a loop? === 39 39 A way to do so is to put the loop into its own method and to add another return. However, you should consider the collection protocol. Usually, there already is a method, that solves your problem. Possible methods could be: `#detect:ifFound:ifNone:` or `#detect:thenDo:ifNone:`. 40 40 41 === Are there abstract classes in !Smalltalk and how should I name them? ===42 In !Smalltalk a class is abstract when a method is implemented with "self subclassResponsibility". However, you can still create objects of this class, but this method cannot be called. A typically idiom is to extend the name with the word "Abstract". Examples in the image are: AbstractEvent, AbstractFont, orAbstractSound.41 === Are there abstract classes in Smalltalk and how should I name them? === 42 In Smalltalk a class is abstract when a method is implemented with "self subclassResponsibility". However, you can still create objects of this class, but this method cannot be called. A typically idiom is to extend the name with the word "Abstract". Examples in the image are: !AbstractEvent, !AbstractFont, or !AbstractSound. 43 43 44 44 == Idioms and Patterns ==