You could use the @pack macro from Parameters.jl: @pack ec.title: show, zlevel, z
which is equivalent to your ec.title.show = show ec.title.zlevel = zlevel ec.title.z = z Otherwise use `setfield!`: function f(t;kws...) for (s,v) in kws setfield!(t, s, v) end end On Tue, 2015-12-29 at 20:34, Randy Zwitch <randy.zwi...@fuqua.duke.edu> wrote: > I feel like I should be so much better at this than I am... > > How can I take code like: > > ec.title.show = show > ec.title.zlevel = zlevel > ec.title.z = z > > And change it to something like > > for val in [:show, :zlevel, :z] > :(ec.title.$val) = :($val) > end > > I'm just trying to dynamically reference and set the value of the composite > type field equal to the values passed to a function's keyword arguments.