from what I can tell Ruby doesn't do true named arguments.
Ruby does doesn't have a true implementation named arguments, that I know
of, but in practice, the Hash comes close.
For example Rails makes frequent use of named parameters, which are just
keys to a Hash.
Here is an example where using the hash is different:
def test(id, params)
if params[:active] == true
test(1, :active=>true, :a=>1, :b=>2, ...)
The first param, id, must be the first argument, but the params Hash can
take up the rest of the arguments.
You would also have to do your own testing to see that certain keys are
defined, if they are required.
On 8/23/05, Kevin Olbrich <firstname.lastname@example.org> wrote:
Actually the section that got me working on this is page 256. Of course at
1 am, I didn't notice that this was in the "windows automation" chapter,
I guess I shouldn't have expected it to work in standard use.
—- it looks like there are a number of hacks and work-arounds to get a
feature *like* this to work, but from what I can tell Ruby doesn't do true
From: Randy Kramer [mailto:email@example.com]
Sent: Tuesday, August 23, 2005 07:15 AM
To: ruby-talk ML
Subject: Re: Named Arguments
On Tuesday 23 August 2005 05:23 am, Brian Schröder wrote:
> I do not know of such a feature and can't find it mentioned in the
> pickaxe. Maybe you have a python pickaxe? Otherwise, could you point
> me to the page where you found it?
Pgs 84 and 85 of Pickaxe 2 discuss / describe hash arguments consisting of
=> value pairs (and discussed as a workaround for keyed (named) arguments.
suspect the OP was thinking of these.