Roelof,
I don't think so.
A Class cannot access instance variables. Why? because a Class doesn't
know which of its instances to ask for it.
Ask yourself: who is "self" in a Class method? Is it the Class or is it
an individual instance of the Class?
(Hint: in a Class, #self is the Class, while in an instance, #self is
the instance) .
"Who" do you want to validate the ISBN number? An individual instance of
your Class (like Book)? Or is validating an ISBNNumber a Task that is
independent of an individual item? If it is independent, then why would
you want to use semething specific in that method?
You need to understand the differences between Class and Instance
variables. I suggest reading Chapter 4 of "The Art and Science of
Smalltalk
<http://stephane.ducasse.free.fr/FreeBooks/Art/artAdded174186187Final.pdf>"
or better: read the whole book. It's easy to read and sparks quite a few
A-HA's per hour.
HTH
Joachim
Am 02.09.20 um 08:18 schrieb Roelof Wobben:
Hello,
I have now a challenge where I have to validate a ISBN number.
Can I do something like this on the class side :
(string isEmpty)
ifTrrue: [ ^ false]
ifFalse: [ digits:= something.
controlDigit := something.
self validateISBNNumber]
where on the validateISBNNumber I use the instance variables digits
and controlDigit to validate the ISBN number on the instance side.
Roelof
--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel mailto:jtuc...@objektfabrik.de
Fliederweg 1 http://www.objektfabrik.de
D-71640 Ludwigsburg http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1