You can write `testvariable=incrementvariable(testvariable)`.
But it's wield to write a dedicated function to implement the increment.
Can't you just write `testvariable+=testvariable`?
On Saturday, August 22, 2015 at 8:49:33 PM UTC+2, Tero Frondelius wrote:
>
> Why testvariable is not incremented?
>
> function incrementvariable(numb)
> numb += 1
> end
> function testing()
> global testvariable = 0
> for i = 1:3
> incrementvariable(Ptr{testvariable})
> end
> println(testvariable)
> end
>
> Or actually what should I change to get the testvariable incremented? I'm
> counting how many times one case inside the function incrementvariable is
> called. I will use this information later in the testing() function.
>
> This will work, but it doesn't look elegant:
> function incrementvariable(numb)
> numb[1] += 1
> end
> function testing()
> testvariable = [0]
> for i = 1:3
> incrementvariable(testvariable)
> end
> println(testvariable)
> end
>
>
>
>