Can the ifTrue be omitted from an if in smalltalk?

151 Views Asked by At

Usually an if in Smalltalk looks like this

condition
        ifTrue: [ ... ]
        ifFalse: [ ... ].

However, I can not find whether it is allowed to omit one of the parts, such as ifTrue: .. or ifFalse ...

Is there a manual that I am missing? I cannot find it.

1

There are 1 best solutions below

3
On BEST ANSWER

Pharo Smalltalk for example knows

  • ifTrue:
  • ifTrue:ifFalse:
  • ifFalse:
  • ifFalse:ifTrue:

I think other dialects understand similar messages. They are part of the ANSI Smalltalk Standard.