josgilmo page

Statistics for quiz "Channels in Go"

Total preguntas: 4
Total de veces intentado completo: 4
Promedio aciertos: 0.5
Total de veces resuelto 100% correcto: 1
Tiempo promedio utilizado : 48:20
Tiempo quiz más rápido: 00:00
Pregunta más veces equivocada: What happens with this piece of code? ```go package main import "fmt" func main() { cc := make(chan int) close(cc) r := <- cc fmt.Printf("%d", r) } ```

Número de aciertos

Ranking top users

Username Points Take
josgilmo 0 00:00
Question Good Fails

What happens with the next code:

package main

func main() {
    var dataStream chan interface{}
    <-dataStream
}
2 1

What happens with this piece of code?

package main

import "fmt"

func main() {
    cc := make(chan int)
    close(cc)
    r := <- cc
    fmt.Printf("%d", r)
}
0 3

What happens with this piece of code?

package main

func main() {
    var dataStream chan interface{}
    close(dataStream)
}
3 1

What happens with this piece of code?


package main

import "fmt"

func main() {

    chanOwner := func() <-chan int {
        resultStream := make(chan int, 5)
        go func() {
            defer close(resultStream)
            for i := 0; i <= 5; i++ {
                resultStream <- i
            }
        }()
        return resultStream
    }
    resultStream := chanOwner()
    for result := range resultStream {
        fmt.Printf("Received: %d\n", result)
    }

    fmt.Println("Done receiving!")
}
3 1