newbie smalltalk question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

newbie smalltalk question

Elliot Finley
I have the following code:

isValid (self value == nil and: [self required == false]) ifTrue: [^true]. self isCorrectType ifFalse: [self validationError: 'value doesn''t coerce to correct type'. ^false.] ^ self allConditionsValid.

when I try to save this I get a ' Nothing more expected ->' right before '^ self allConditionsValid'.  I'm guessing this is because I have the '^false' in the second line?

How would I accomplish the same thing - correctly?

Thanks,
Elliot

Reply | Threaded
Open this post in threaded view
|

Re: newbie smalltalk question

Eliot Miranda-2


On Thu, Dec 2, 2010 at 9:49 PM, Elliot Finley <[hidden email]> wrote:
I have the following code:

isValid (self value == nil and: [self required == false]) ifTrue: [^true]. self isCorrectType ifFalse: [self validationError: 'value doesn''t coerce to correct type'. ^false.] ^ self allConditionsValid.

when I try to save this I get a ' Nothing more expected ->' right before '^ self allConditionsValid'.  I'm guessing this is because I have the '^false' in the second line?


You are missing a period after the close of the block.  You have a period /before/ the end of the block, which is unnecessary.  Move it to the other side of the ']'.

best
Eliot
   
How would I accomplish the same thing - correctly?

Thanks,
Elliot


Reply | Threaded
Open this post in threaded view
|

Re: newbie smalltalk question

Elliot Finley
On Thu, Dec 2, 2010 at 10:59 PM, Eliot Miranda <[hidden email]> wrote:


On Thu, Dec 2, 2010 at 9:49 PM, Elliot Finley <[hidden email]> wrote:
I have the following code:

isValid (self value == nil and: [self required == false]) ifTrue: [^true]. self isCorrectType ifFalse: [self validationError: 'value doesn''t coerce to correct type'. ^false.] ^ self allConditionsValid.

when I try to save this I get a ' Nothing more expected ->' right before '^ self allConditionsValid'.  I'm guessing this is because I have the '^false' in the second line?


You are missing a period after the close of the block.  You have a period /before/ the end of the block, which is unnecessary.  Move it to the other side of the ']'.


<me turning bright red with embarrassment> 
Thank you. 
</>