0
如果Obj是本地的,則下面的新函數不起作用。如果我從/本地刪除它的作品。那麼該怎麼做才能使它與本地的Obj一起工作,謝謝?當然不難爲你。Rebol和/ local對象
Person: make object! [
Person: func[FirstName LastName][
Self/FirstName: FirstName
Self/LastName: LastName
Print Self/FirstName
Print Self/LastName
]
FirstName: ""
LastName: ""
]
new: func[Class [Object!] Param-Block [block!] /local Obj][
Constructor: to-word pick pick Class 1 2
Obj: Make Class []
params: copy ""
foreach param Param-Block [
if string? param [
param: rejoin [{"} param {"}]
]
append params param
append params " "
]
do rejoin [{do get in Obj Constructor} { } params]
Obj
]
;FOR TEST
John: new Person["John" "Doe"]
還會送
>> probe John
make object! [
Person: func [FirstName LastName][
Self/FirstName: FirstName
Self/LastName: LastName
Print Self/FirstName
Print Self/LastName
]
FirstName: ""
LastName: ""
]
>>
也就是說名字和姓氏是 「」,而不是 「約翰」, 「李四」
它擔任預計當我嘗試它。你遇到什麼問題? – 2009-12-17 11:13:35
你已經設置了John在測試用例中返回的新值,它是值爲{「John」「Doe」}的字符串。 – 2009-12-17 11:16:36
複製錯誤版本,以便在新的版本中返回Obj。 我的問題是: – 2009-12-17 23:28:00