logo       

subclasses detect: msg#00151

lang.smalltalk.squeak.beginners

Subject: subclasses detect


Hello

In the laser game tutorial by Stephan B Wessels I was intrerested by this
code:

directionFor: aSymbol
^ self subclasses
detect: [:cls | cls directionSymbol = aSymbol]

The code appears here at the bottom of the page:
http://squeak.preeminent.org/tut2007/html/038.html

What I read this code as doing, in this example is: return an symbol object
which is a sublass instance varable, if it is the same as aSymbol.

What would happen if more than one subclass object had a match?

Also how else can subclasses detect: be used? It looks very interesting.

Grunt


--
View this message in context:
http://www.nabble.com/subclasses-detect-tf4196202.html#a11934239
Sent from the Squeak - Beginners mailing list archive at Nabble.com.


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise