LEARN GOLANG QUICKLY AND PYTHON CODING PRACTICE EXERCISES: Coding For Beginners by TAM JJ

LEARN GOLANG QUICKLY AND PYTHON CODING PRACTICE EXERCISES: Coding For Beginners by TAM JJ

Author:TAM, JJ [TAM, JJ]
Language: eng
Format: epub, azw3, mobi
Published: 2021-07-18T16:00:00+00:00


Output

Default block is executed

Just like ‘if’ statement in Go, you can add initialization in switch statement itself.

switch a :=10; a {

}

HelloWorld.go

package main

import "fmt"

func main() {

switch a := 10 ; a {

case 10 :

fmt.Println( "Value of a is 10" )

case 20 :

fmt.Println( "Value of a is 20" )

default :

fmt.Println( "Default block is executed" )

}

}

Output

Value of a is 10

You can even omit the expression after switch statement.

HelloWorld.go

package main



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.