func spinner(delay time.Duration) {
for {
for _, r := range `-\|/` {
fmt.Printf("\r%c", r)
time.Sleep(delay)
}
}
}
go spinner(100 * time.Millisecond)
def spinner(delay : Time::Span)
loop do
"-\|/".each_char { |c|
printf("\r%c", c)
sleep delay
}
end
end
spawn spinner(0.1.seconds)
for {
conn, err := listener.Accept()
if err != nil {
log.Print(err)
continue
}
go handleConn(conn)
}
loop do
conn = listener.accept
spawn handle_conn(conn)
rescue ex
puts ex
end
loop do
if conn = listener.accept?
spawn handle_conn(conn)
end
end
for {
conn, err := listener.Accept()
if err != nil {
log.Print(err)
continue
}
go handleConn(conn)
}
class Channel(T)
def listen(&block : T ->)
loop do
block.call(self.receive)
rescue Channel::ClosedError
break
end
end
end
for x := range naturals {
squares <- x * x
}
close(squares)