So something like: function update_ts(pe::PricingEngine, newTS::TermStructure) newPE = PricingEngine(pe.varA, pe.varB, newTS) return newPE end
myPE = PricingEngine(4.5, 5.5, TermStructureA()) myPE = update_ts(myPE, TermStructureB()) You probably wouldn't be able to update the "myPE" object in place right (i.e. updating it in the actual update_ts method and then returning itself)? On Monday, February 1, 2016 at 1:50:41 PM UTC-5, Tom Breloff wrote: > > You could just construct a new object with the new TermStructure, instead > of overwriting the old one. > > On Mon, Feb 1, 2016 at 1:27 PM, Christopher Alexander <uvap...@gmail.com > <javascript:>> wrote: > >> Hello all, I have a question about the usage of parametric types. I know >> these bring about a performance boost (at least that was my understanding), >> but I have a situation where I have a parametric type defined as such: >> >> type PricingEngine{T <: TermStructure} >> varA::Float64 >> varB::Float64 >> ts::T >> end >> >> >> But then I need to actually swap the existing term structure with another >> subtype of TermStructure further down the road. Using parametric types, it >> complains because I guess it's locked in to using whatever TermStructure >> sub type is initially there when I instantiate the PricingEngine type. Is >> there anyway to do such an update while still using a type parameter, or am >> I stuck just with a definition that uses the broader abstract type? >> >> Thanks! >> >> Chris >> > >