Hey all, wondering about this…
tick :t1, offset: 1, step: 2
works in a loop …*
#1,3,5,7
I tried generating some varieties using things like .each
but it doesn’t seem to work as expected, similarly with my first dabble with tick_set
which I tried as a workaround.
v1
tick, offset,steps
t1,1,1 #1,2,3,4
t2,2,2 #2,4,6,8
t3,3,3 #3,6,9,12
t4,4,4 #4,8,12,16
At first I thought the problem was how I was using them, but appears the issue is when using the two options combined.
step: The amount to tick up by. Default is 1.
offset: Offset to add to index returned. Useful when calling tick on lists, rings and vectors to offset the returned value. Default is 0.
Observations:
- when initialising a tick (named or anonymous) it defaults to 0, unless step is used, then the first value is
step-1
(*this is why only the first use-case works, offset: 1, steps: 2, ∴ the desired offset (1) is the offset used (2-1)
live_loop :ticker do
puts tick :a, step: 3 #2,5,8
wait 1
end
- when using offset as a single argument the initial value can be set
puts tick :a, offset: 3 #3,4,5
- when combining the two to try to step every n steps from offset x, this fails.
Is this a bug?
Or is tick not meant to be used like this?
Also any workarounds?
Finally is it possible to get at the previous value?
I know it’s a longshot but I remember reading about how times are managed using threads and get set… a bit like rand_back
but for ticks…
Thanks!