[Newbies] Re: FileDirectory
joseph.alotta at gmail.com
Thu May 26 19:02:10 UTC 2016
> On May 26, 2016, at 8:29 AM, Ron Teitelbaum [via Smalltalk] <ml-node+s1294792n4897552h61 at n4.nabble.com> wrote:
> One more question for you. I mentioned returning a newly created instance or a specific class from a class side method. Can you name another reason why you would write a method on the class side?
When you want the class as a whole to do something. When there is only one instance of an object and other is not desirable or logical.
For example, one compiler: two is not practical. One instance of the number Pi. One instance of Nil. Why would you need another?
> Why would it be a good idea to put a method on the class side instead of the instance side? (a hint for you, I’m thinking of something where nothing is returned. (of course in Smalltalk if nothing is returned you get back self, what I mean is that nothing useful is returned)) Bonus points for 2 or more answers with or without returning
> something J.
You would put a method on the class side when the method applies to all instances of the class. For example, Window closeAllWindows. Or Process stopAllProcesses. Or Smalltalk saveImage.
I don’t think this is what you had in mind, though.
View this message in context: http://forum.world.st/FileDirectory-tp4897377p4897621.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners