2010-05-03 66 views
1

從芬奇音頻庫:「foo =(foo + 1)%bar」究竟幹什麼?

- (void) play 
{ 
    [[sounds objectAtIndex:current] play]; 
    current = (current + 1) % [sounds count]; // this line here... 
} 

我試圖神交它:有一些聲音ñ,並current是在每次迭代增加1。只要current大於聲音的數量n,模數返回零。這樣,它從一開始就開始。

這是正確的嗎?

回答

8

是的,沒錯。

相關問題