Skip to content

Instantly share code, notes, and snippets.

@notyy
Created November 6, 2011 16:53
Show Gist options
  • Save notyy/1343162 to your computer and use it in GitHub Desktop.
Save notyy/1343162 to your computer and use it in GitHub Desktop.
bad
def test3() {
val fruits = Array("apple", "orange", "banana")
for (i <- fruits.indices) {
val fruit = fruits(i)
Actor.actor {
for (j <- 1 to 3) {
println(j+" : "+fruit)
Thread.sleep(5000)
}
}
}
}
@ggd543
Copy link

ggd543 commented Nov 6, 2011

In order not to be confused , it ts better change the code snippet println(j+" : "+fruit) to println((i + j) +" : "+fruit)

·

@ggd543
Copy link

ggd543 commented Nov 6, 2011

def test3() {
val fruits = Array("apple", "orange", "banana")
for (i <- fruits.indices) {
val fruit = fruits(i)
Actor.actor {
for (j <- 1 to 3) {
println(j+" : "+fruit)
Thread.sleep(5000)
}
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment