Symbol(String($symbol)) in quotes

Hi all :slight_smile:

I need the following:

quote 
    :symbol
end

is there a better way for doing this:

julia> symbol = :symbol
:symbol

julia> quote
           Symbol(String($symbol))
       end
quote
    Symbol(String($symbol))
end

So what I need is basically a symbol in a quote but the value of the symbol comes from outside

Thanks

You can use QuoteNode:

julia> symbol = :symbol;

julia> quote
           $(QuoteNode(symbol))
       end
quote
    #= REPL[2]:2 =#
    :symbol
end
3 Likes