grabbing value of a variabe by its name?
Alan Kay
Alan.Kay at squeakland.org
Thu Jul 25 15:09:51 UTC 2002
Ragnar --
I think the construct that is most like you are looking for would be
to type the following into a workspace and execute them with a "cmd
(or alt) d":
foo _ 'hello'.
bar _ 'world'.
baz _ { foo. bar}.
If you then type
baz
and execute this with a "print it" -- a "cmd (or alt) d", then you will see
#('hello' 'world')
But the suggestion below will also work. The construct:
baz _ Array with: foo with: bar
will put the very same Array structure into baz, and you can see this
by executing:
baz
with a "cmd (or alt) d"
Cheers,
Alan
-----
At 3:28 PM +0200 7/25/02, Ragnar Hojland Espinosa wrote:
>On Thu, Jul 25, 2002 at 07:22:03AM -0500, Martin McClure wrote:
>> At 1:42 PM +0200 7/25/02, Ragnar Hojland Espinosa wrote:
>> >foo _ 'hello'.
>> >bar _ 'world!'.
>> >baz _ #(foo bar).
>> >
>> >I can get the name of the var by a (baz at: 1), but how do i get its value?
>>
>> The construct "#(foo bar)" specifies a literal Array that contains
>> two literally-specified Symbols, #foo and #bar. It does not reference
>> any variables.
>>
>> One way to get what you're looking for is
>>
>> baz _ Array with: foo with: bar.
>
>Uhh, i dont see how.. please elaborate a bit. The following would work, but
>it saves nothing.
>
>baz _ at: 'foo' put: foo.
>baz _ at: 'bar' put: bar.
>
>
>--
>Ragnar Hojland - Project Manager
>Linalco "Especialistas Linux y en Software Libre"
>Tel: +34-91-5970074 Fax: +34-91-5970083
--
More information about the Squeak-dev
mailing list
|