From: "Dwayne Smurdon @ DNA Media Pro" Date: 2003-02-02T20:42:23+09:00 Subject: dynamic method name...was RE: hash question... This is a multi-part message in MIME format. ------=_NextPart_000_000C_01C2CA85.E16DB640 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit First -- thanks Guy, that solved that problem and allowed me to find and move on to the next. Let's say I have a reference to an object called "contact" and it has an attribute "phone". The atrribute phone can be legally set like this: contact.phone = "703-277-7272" But, let's say I have a variable, called meth. And meth == "phone". I want to use my variable meth like this: contact.meth = "703-277-7272" # this should set phone I tried using @meth, but I get a parse error. How would I go about doing this? -Dwayne > -----Original Message----- > From: ts [mailto:decoux@moulon.inra.fr] > Sent: Sunday, February 02, 2003 6:04 AM > To: ruby-talk ML > Cc: ruby-talk@ruby-lang.org > Subject: Re: hash question... > > > >>>>> "D" == Dwayne Smurdon @ DNA Media Pro > writes: > > D> map.keys.each |a| { person.a = rs.Fields(map[a]).Value } > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > This is interpreted as an Hash, you must write > > map.keys.each {|a| person.a = rs.Fields(map[a]).Value } > ^^^^ > > now it's interpreted as a block > > D> D:/Apps/Ruby/projects/OutlookContact.rb:29: odd number > list for Hash > > This error message is for this > > pigeon% ruby -e 'hash = { 1 }' > -e:1: odd number list for Hash > pigeon% > > pigeon% ruby -e 'hash = { 1, 2 }' > pigeon% > > pigeon% ruby -e 'hash = { 1, 2, 3 }' > -e:1: odd number list for Hash > pigeon% > > > Guy Decoux > > ------=_NextPart_000_000C_01C2CA85.E16DB640 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable dynamic method name...was RE: hash question...

First -- thanks Guy, that solved that problem and = allowed me to find and move on to the next.

Let's say I have a reference to an object called = "contact" and it has an attribute "phone".  The = atrribute phone can be legally set like this:

contact.phone =3D "703-277-7272"

But, let's say I have a variable, called meth.  = And meth =3D=3D "phone".  I want to use my variable meth = like this:

contact.meth =3D "703-277-7272"  # this = should set phone


I tried using @meth, but I get a parse error.  = How would I go about doing this?

-Dwayne


> -----Original Message-----
> From: ts [mailto:decoux@moulon.inra.fr]
> Sent: Sunday, February 02, 2003 6:04 AM
> To: ruby-talk ML
> Cc: ruby-talk@ruby-lang.org
> Subject: Re: hash question...
>
>
> >>>>> "D" =3D=3D Dwayne = Smurdon @ DNA Media Pro
> <smurdon@dnamediapro.com> writes:
>
> D> map.keys.each  |a| { person.a =3D = rs.Fields(map[a]).Value }
>          =              = ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  This is interpreted as an Hash, you must = write
>
>    map.keys.each   {|a| = person.a =3D rs.Fields(map[a]).Value }
>          =           ^^^^
>
>  now it's interpreted as a block
>
> D> = D:/Apps/Ruby/projects/OutlookContact.rb:29: odd number
> list for Hash
>
>  This error message is for this
>
> pigeon% ruby -e 'hash =3D { 1 }'
> -e:1: odd number list for Hash
> pigeon%
> 
> pigeon% ruby -e 'hash =3D { 1, 2 }'
> pigeon%
>
> pigeon% ruby -e 'hash =3D { 1, 2, 3 }'
> -e:1: odd number list for Hash
> pigeon%
>
>
> Guy Decoux
>
>

------=_NextPart_000_000C_01C2CA85.E16DB640--