Initializing instance variables from the parameter list
While looking at NegaPosi, a crazy Ruby implementation of a micro language that only uses unary operators, I discovered a cute way to initialize instance variables. Usually you'd do this:
def initialize @p =  @b =  end
But, how about doing it this way?
def initialize a=@p=, b=@b= end
Initialize doesn't require the parameters, but it forces @p and @b to be initialized as arrays whenever an instance is created. Cute trick, although the readability suffers.
Technorati Tags: ruby