On 8/13/16, Adrian Salceanu <[email protected]> wrote:
> Hi,
>
> This seems to be a recurring question per my googlings, but still I could
> not find a satisfactory answer.
>
> I'm looking for a generic way of doing this:
>
> render_template(template_content, Dict(:greeting => "Hello", :greeted =>
> "World", :other => Dict("foo" => 1)))
>
> where
>
> function render_template(template_content, template_vars = Dict{Symbol,Any
> }())
>   # here instantiate template_vars keys with corresponding values, so that
>   # greeting = "Hello"
>   # greeted = "World"
>   # other = Dict("foo" => 1)
> end

greating = pop!(template_vars, :greating) # possibly with default value
greated = pop!(template_vars, :greated) # possibly with default value
other = template_vars

there's no way you can introduce a local variable without explicitly
assigning to it and this is a crucial property of the semantics.

>
> Thanks!
>

Reply via email to