[Newbies] Assignment

Maurice van Peursem squeak at vanpeursem.net
Thu Aug 9 23:24:03 UTC 2007


Hi,

I'm new to Squeak, and working through 'Squeak by Example' 
(http://www.squeak.org/Documentation/). I'm confused by the example 
on page 49 (Method 4.2):

lineCount
"Answer the number of lines represented by the receiver, where every
cr adds one line."
| cr count |
cr Character cr.
count 1 min: self size.
self do:
[:c | c == cr ifTrue: [count count + 1]].
^ count

What exactly does the following line mean?
cr Character cr.

I (as Perl programmer) would write:
cr := Character cr.

and:
[:c | c = cr ifTrue: [count count + 1]].

Can anyone explain the difference?

Thanx,
Maurice


More information about the Beginners mailing list