[REBOL] Re: Newbie query on array indexing
From: greggirwin:mindspring at: 21-Nov-2001 22:23
Hi John,
<< While Rebol is certainly powerful it seems to have plenty of quirks
waiting to trip the unwary - maybe it gets better the more you get into it!
>>
I think it's like learning to ride a motorcycle. At first you take it slow
because you know you don't know what you're doing. After a while, you
*think* you know what you're doing, but it isn't for quite some time that
the process becomes part of your psyche and you can just "do it" without
thinking about it. Only with REBOL it more than "1 down - 4 up". :)
<< I still could not get the following type of array element assignment
reference to work (this was my original approach):-
; define array
example-array: array/initial 10 ""
; define index
idx: 3
; try to set element at offset defined by index value
example-array/:n : "data"
Different syntax required? >>
You can use either 'pick, as Brett suggested, or 'change as I suggested.
They differ in what they return to you, so that's something to be aware of.
Look at help on each of them to see what I mean.
If you're reading the value, example-array/:n will work, but you can't set
the value with that syntax.
With REBOL you'll find that you need to think about things differently. When
you can let go of how other languages work (I'm still working on that, BTW)
it will get easier and you'll write more REBOLish code which, at least for
me, is very different from what I would write in another language.
HTH!
--Gregg