2017-01-06 09:53:40 +00:00
|
|
|
class Boolean(Object)
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
(* TODO: do i need to really define methods defined in True and False here?
|
|
|
|
and call subclassResponsibiltiy?" *)
|
2015-10-08 14:26:04 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
class True(Boolean)
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
method not
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method & aBoolean
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^aBoolean
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method | aBoolean
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^true
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method and: aBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^aBlock value
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method or: aBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^true
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method ifTrue: trueBlock ifFalse: falseBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^trueBlock value.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method ifTrue: trueBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^trueBlock value.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method ifFalse: falseBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^nil.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
class False(Boolean)
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
method not
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^true
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method & aBoolean
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method | aBoolean
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^aBoolean
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method and: aBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method or: aBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^aBlock value
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method ifTrue: trueBlock ifFalse: falseBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^falseBlock value.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method ifTrue: trueBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^nil.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method ifFalse: falseBlock
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
|
|
|
^falseBlock value.
|
|
|
|
}
|
|
|
|
}
|