setfield!(inst, symbol(varToChange), 20)

On Saturday, September 13, 2014 4:47:46 PM UTC-7, [email protected] wrote:
>
>
> Hi All,
>
> Suppose I have a composite type and an instance of it:
>
> type myType
>            numLines::Int
>            avgLength::Float64
>        end
>
> inst = myType(10, 8.5)
>
>
> I want to change, say numLines of inst1 to 20. I know I can do 
>  
>
> inst.numLines = 20
>
>
> However, suppose the field that has to be changed is determined by the 
> program. Say, I have, 
>
> varToChange = "numLines"
>
> How can I use *varToChange* to change the value of *numLines* in *inst*? 
>
> Thank you.
>
>
>
>

Reply via email to