Gavin,

Thanks for that.  I have been pointed toward irb a couple of times, but 
I really need to get use to using it for this sort of thing.  thanks for 
the pointer.

cheers
dim

Gavin Sinclair wrote:
> On Tuesday, January 21, 2003, 11:03:25 AM, Dmitri wrote:
> 
> 
>>Gavin Sinclair wrote:
>>
>>>>:) Yes... actually I guess you'd have to default it to
>>>>nil if you actually wanted it to accept NO ARGUMENT 
>>>>passed in:  def foo(foobar=nil)
>>>
>>>Just to emphasise the point.  If you call *your* code with no
>>>argument, the parser or whever you call it will spit the dummy.  Just
>>>as zero is a number, nil qualifies as an argument.
> 
> 
>>I'd effectively get a 'array index out of bounds' error or something 
>>yeah?
> 
> 
> Try it and see (that's what irb is for):
> 
>    >> def foo(foobar)
>    >>   puts (foobar || 9)
>    >> end
>    => nil
> 
>    >> foo
>    ArgumentError: wrong # of arguments(0 for 1)
>            from (irb):7:in `foo'
>            from (irb):7
> 
>    >> foo(nil)
>    9
>    => nil
> 
>    >> foo("son of a gun")
>    son of a gun
>    => nil
> 
> If you haven't used irb before, get used to it!  It was invoked with
> --simple-prompt above (why isn't there a short command for that?).
> The "nil" after each method invocation are the return value of the
> method, which is the r/v of puts, which is always nil.  When mucking
> around in irb, there's no need to use puts in examples like the above,
> e.g.
> 
>    >> def foo(foobar)
>    >>   foobar || 9
>    >> end
>    => nil
> 
>    >> foo
>    ArgumentError: wrong # of arguments(0 for 1)
>            from (irb):4:in `foo'
>            from (irb):4
> 
>    >> foo(nil)
>    => 9
> 
>    >> foo("sun of a gun")
>    => "sun of a gun"
> 
> irb is too useful to ignore.
>    
> Gavin
> 
>