[REBOL] Re: Block building
From: ingo:2b1 at: 24-Nov-2002 23:13
Hi Ted and Scott,
G. Scott Jones wrote:
> Hi, Ted,
>
> From: Ted Landis
>
> <...>
> If you have really dynamic code, and therefore don't know in advance
> what components are in the object, you can take advantage of getting
> 'first on the object:
Or you could use 'second
>> probe second object1
[
make object! [
String1: "ABC"
Block1: ["DEF" "GHI"]
Block2: ["JKL" "MNO" "PQRSTUVWXYZ"]
] "ABC" ["DEF" "GHI"] ["JKL" "MNO" "PQRSTUVWXYZ"]]
== [ ...
As you see, 'second object! returns the object! itself, followed by a
list of all values. So, you could use something like this:
>> block: copy []
== []
>> repeat value next second object1 [ insert block value ]
== ["DEF" "GHI" "ABC"]
>> block
== ["JKL" "MNO" "PQRSTUVWXYZ" "DEF" "GHI" "ABC"]
Kind regards,
Ingo