Search code examples
rebolred-lang

Red: any alternative to using do for adding dynamic keys to a block


Is there an alternative syntax for :

a: [
b: [
    1 2
]
]

append (do "a/b") 3   

== [
    b: [
        1 2
    ]
] 

I don't feel this as very elegant using do (it ressembles too much eval in javascript).

I tried to-path without success.


Solution

  • Re comment that you want a/b in a variable:

    a: [b: [1 2 3]]
    var: a/b
    append var 4
    probe a
    == [b: [1 2 3 4]]