help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Re: Objects and classes


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: Objects and classes
Date: Wed, 28 May 2008 17:44:41 +0200
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)


But you can define class side methods (often as convenient
abbreviations) for creating new instances, which "hide" the call to new
within their implementation, your fileIn above is one such example. It's implementation might very well look like:

fileIn: aPath
        ^self new fileIn: aPath

Just guessing, but it's a common pattern.

Yes, in this case it's another common usage of class methods, i.e. "create an object, do something, discard it". fileIn: is implemented as


   ^(self open: aPath mode: self read)
        fileIn;
        close

(more or less).

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]