There is simply no point in "taking the first nine numbers out". And there shouldn't BE a test for the string being empty, anywhere. '' '-' '---' and so on should all be handled the same way.
Oh well, what stops you doing digits := aString select: [:each | each ~= $-]. digits size = 10 ifFalse: [^false]. lastDigit := digits la ost. digits := digits copyFrom: 1 to: 9. ( (lastDigit = $X or: [lastDigit isDigit]) and: [ digits allSatisfy: #isDigit] ) ifFalse: [^false]. Now my code does not do this, but it is just 16 lines of code with nothing that it would make sense to extract. On Wed, 2 Sep 2020 at 22:24, Roelof Wobben <r.wob...@home.nl> wrote: > Yep, I know that isValidIsbn is the method that must output if a isbn is > valid or not. > > What I want to do is take the first 9 characters out so I can convert > them to a array of numbers where I can do the calculation on. > And take out the last char so I can seperate test if that is a valid > char. So between the 0 and 9 or a X > > I do not think I would have do all the checks in that only method > because it would be a very big method then. > > but if I understand you well also the test if a string is empty should > be called from the isValidIsbn method or even checked there. > > Roelof > > >