[REBOL] Re: How do I dynamically modify an object?
From: greggirwin:mindspring at: 14-Jan-2003 14:19
Hi Ed,
ED> Using the examples from the REBOL On-line dictionary:
ED> >> Example: Make Object! [ Name: "Fred" Age: 5000000 ]
ED> >> Get in Example 'Name
ED> == "Fred"
ED> >> Set in Example 'Name "Fred Flintstone"
ED> == "Fred Flintstone"
example/name: "Fred Flintstone"
ED> How do I dynamically add to example, after it has been created, Address:
ED> "123 Bedrock Path".
ED> I tried using 'Set, 'Make and a couple other functions, but they didn't
ED> work. I was probably using them wrong. :)
Just use your object as a prototype with MAKE and put your new field
in the spec block.
example: make example [address: "123 bedrock path"]
make object! [
Name: "Fred Flintstone"
Age: 5000000
address: "123 bedrock path"
]
-- Gregg