On Aug 9, 2007, at 7:45 PM, Blake wrote:
What exactly does the following line mean?
cr Character cr.
A typo? Unless by some means I don't understand a nil object is
supposed to understand the message "Character".
I (as Perl programmer) would write:
cr := Character cr.
I would think that's right.
[:c | c = cr ifTrue: [count count + 1]].
Smalltalk has "=" and "==" as assignment and comparison
respectively. So you need the "==" to compare c to cr.
It also should be "count := count + 1", I believe.
I agree with Blake - I think it's a typo and should be ":=", for
assignment.
To clarify, "=" and "==" are different variants of comparison.
Usually "=" is used for value comparison - for example, two different
lists that had the same contents would be "=" equal. "==" means "is
the same object".
To illustrate, you can try printing
#(a b c) = #(a b c) copy "true"
#(a b c) == #(a b c) copy "false"
(For many objects, these concepts are one and the same - they don't
have any separate idea of value equality, and the default "=", on
Object, is implemented in terms of "=".)
In my experience, it's idiomatic to use "=" for most things, and use
"==" when you really mean "must be the same object".
Hope this helps,
Benjamin Schroeder
_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners