“TIPO SWITCH GOLANG” Respostas de código

TIPO SWITCH GOLANG

var x interface{} = "foo"

switch v := x.(type) {
case nil:
    fmt.Println("x is nil")            // here v has type interface{}
case int: 
    fmt.Println("x is", v)             // here v has type int
case bool, string:
    fmt.Println("x is bool or string") // here v has type interface{}
default:
    fmt.Println("type unknown")        // here v has type interface{}
}
Difficult Dotterel

Switch de Golang

func main() {
	i := 2
    switch i {
    case 1:
        fmt.Println("one")
    case 2:
        fmt.Println("two")
    case 3:
        fmt.Println("three")
    }
}
Radu Cuziac

Switch de Golang

	package main 
    
    my_number := 2
    fmt.Print("Write ", my_number, " as ")
    
    switch my_number {
      case 1:
          fmt.Println("one")
      case 2:
          fmt.Println("two")
      case 3:
          fmt.Println("three")
      default :
          // default case 
    }

Long Lemur

Switch Type Golang

var value interface{} = "Hello Grepper"
switch vale.(type){
	case string:
    	fmt.Println("It is a string")
    case int:
    	fmt.Println("It is a int")
    default:
    	fmt.Println("Not sure")
}
Zany Zebra

Mudar em Golang

switch day {
  case "sunday":
    // cases don't "fall through" by default!
    fallthrough

  case "saturday":
    rest()

  default:
    work()
}
Harendra

Respostas semelhantes a “TIPO SWITCH GOLANG”

Perguntas semelhantes a “TIPO SWITCH GOLANG”

Mais respostas relacionadas para “TIPO SWITCH GOLANG” em Go

Procure respostas de código populares por idioma

Procurar outros idiomas de código