Mark Hubbart
9/29/2004 10:28:00 PM
On Sep 29, 2004, at 3:08 PM, James Edward Gray II wrote:
> Quick question. When I run:
>
> <snip>
>
> James Edward Gray II
>
> P.S. I wanted to collapse those math defs to one line for easy
> reading and found the semicolon trick used above. Is that the only
> way to do it, or is there a method similar to if ... then ... end?
The other questions were answered pretty well, so I'll just answer the
last one. You can either use the semicolon, or specify an empty
parameter list:
def add; return binary { |l, r| l + r } end
def add() return binary { |l, r| l + r } end
The empty parameter list looks cleaner, imho, though it *is* one
character longer.
cheers,
Mark