# Re: Smalltalk's favorite Boolean method

**URL:** <https://www.ruby-forum.com/t/re-smalltalks-favorite-boolean-method/57499>\
**Category:** Ruby\
**Created:** [April 11, 2006, 3:32pm UTC](https://www.ruby-forum.com/t/re-smalltalks-favorite-boolean-method/57499 "2006-04-11T15:32:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KroegerS\_Simon\_Sext](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/57b2e6/32.png) [@KroegerS\_Simon\_Sext](https://www.ruby-forum.com/u/KroegerS_Simon_Sext)\
**Post date:** [April 11, 2006, 3:32pm UTC](https://www.ruby-forum.com/t/re-smalltalks-favorite-boolean-method/57499/1 "2006-04-11T15:32:29Z")

</div>

> Recently, Ruby “got me” and I was wondering how the  
> famous ifTrue:ifFalse: could be added to the System.
> 
> 1 = 2  
> ifTrue:  
> [Transcript show: “true!”]  
> ifFalse:  
> [Transcript show: “false!”]  
> […]

## What about:

def true.ifTrue  
yield; self  
end

def true.ifFalse  
self  
end

def false.ifTrue  
self  
end

def false.ifFalse  
yield; self  
end

(1==2).  
ifTrue {p “true!”}.  
ifFalse {p “false!”}

## (1!=2). ifTrue {p “true!”}. ifFalse {p “false!”}

But note that in ruby not only true is ‘true’  
but every object other than nil or false.

cheers

Simon
