小编Lad*_*lav的帖子

不使用"copy"处理字符串时究竟发生了什么?

下面这个函数的目的是返回一个在两个星之间插入参数值的字符串.

star-name: func [name /local stars] [
    stars: "**"
    insert next stars name
    stars
]
print star-name "test" ;*test*
print star-name "this" ;*thistest*, but what I really want is *this*  
Run Code Online (Sandbox Code Playgroud)

第二次调用函数时,第一次调用的参数仍然是插入的.我知道答案是使用copy "**".我的问题是,每次调用函数时,它是否都不会重新分配stars变量"**"

rebol rebol3

9
推荐指数
1
解决办法
200
查看次数

标签 统计

rebol ×1

rebol3 ×1