Thanks alot Cameron & Jared.

This makes much more sense now & the composite type seems more usable. I 
had erroneous & conflicting expectations of how I would interact with the 
events data structure after preallocating it. 

I'm going to try it out & see how it fits into a larger scale project. 

On Friday, July 22, 2016 at 3:19:26 PM UTC-4, Cameron McBride wrote:
>
>
> On Fri, Jul 22, 2016 at 3:09 PM, Cameron McBride <[email protected] 
> <javascript:>> wrote:
>
>> julia> function get_event(v::Vector{ExampleEvent}, i)
>>          n = length(v)
>>          if i > n
>>            for j in n:i
>>                push!(v, ExampleEvent("",0,0,0,0,0,0)) # default values
>>            end
>>          end
>>          v[i]
>>        end
>>
>
> haha, that creates one extra element (ExampleEvent row) on the first pass. 
> Whoops. Here is a quick fix. Likely better ways to do all this, just 
> kicking it further.
>
> julia> function get_event(v::Vector{ExampleEvent}, i)
>          n = length(v)
>          if i > n
>            i1 = n > 0 ? n : 1
>            for x in i1:i
>                push!(v, ExampleEvent("",0,0,0,0,0,0)) # default values
>            end
>          end
>          v[i]
>        end
>
> Cameron
>

Reply via email to