[REBOL] Re: Object -> Word?
From: chris-ross::gill::com at: 19-Dec-2007 23:14
On Dec 19, 2007 9:08 PM, Kai Peters <kpeters-otaksoft.com> wrote:
>> o1: make object! []
>> o2: make object! []
>>
>> probe type? o2
object!
== object!
>>
>> s: [ o1 o2 ]
== [o1 o2]
>>
>> probe type? s/1
word!
== word!
> Hmm - why the type change here from object to word?
>
> More importantly, how do I overcome this?
>
> I need to iterate over all the objects in a block and operate
> on them as objects - not words...
No type change here. [o1 o2] is just a block of words. In a block,
they are just words, though they are bound to the context they are
generated in. The two main options you have are:
>> foreach obj reduce s [probe obj]
>> foreach word s [probe get/any :word]
Note: you don't need to use a get-word! in the second example - in
some cases, the intent is clearer.
- Chris