> in smalltalk
>
> factorial
>
>   ^self = 0 ifTrue: [ 1 ] ifFalse: [ self * ((self-1) factorial) ]
>
> the message #ifTrue:ifFalse: is implemented in the class Boolean and
> in his subclasses, and receive two block argmuments, the behavior if
> the boolean is true and the behavior if the boolean is false.

BTW, you _can_ implement if/else in Ruby using methods alone.

That smalltalk line can be written in Ruby as...

(self == 0).ifelse lambda { 1 }, lambda { self * ((self-1).factorial) }

...if you bother to define an 'ifelse' method for Object:

class Object
  def ifelse(true_block, false_block)
    if self
      true_block.call
    else
      false_block.call
    end
  end
end
-- 
Posted via http://www.ruby-forum.com/.