Golang Tutorial #11 - Switch Statement

preview_player
Показать описание
This golang tutorial covers the switch statement. The switch statement is an alternative to the if/else if structure. It allows you to check the value of a specific variable and execute different cases based on that value.

◾◾◾◾◾
💻 Enroll in The Fundamentals of Programming w/ Python

◾◾◾◾◾◾

⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡

⭐ Tags ⭐
- Tech With Tim
- Golang tutorial
- Golang Switch Statement
- Golang Switch
- Switch Tutorial Golang

⭐ Hashtags ⭐
#GO #Golang
Рекомендации по теме
Комментарии
Автор

From my limited understanding, in contrast to most other languages, In golang you do not have to break after each case, as it breaks by default, and if you wish to continue execution, you have to explicitly use the keyword "fallthrough" to continue execution of the next case statement (without checking the condition of course).
TLDR : in most other languages, case continues execution until it encounters a break, in go, it's the opposite, it breaks everytime unless you use fallthrough.

amineabdz
Автор

Man, I'm loving this series, learning so much, you do know how to explain everything

enriquesnetwork
Автор

Awesome videos Tim, keep up the good work. A GO GUI tutorial would be awesome to see next :)

rthu
Автор

Hey ! Great video ! You could have talked about "fallthrough" option in the cases. Anyway, great tutorial keep it going ! :)

nicolasmf
Автор

From what i see if Switch has a variable declared then you can use operand only like = one number, if you want to use >= then u have to leave the swich blank and declare the variable you wanna check into the case.
Not sure why, and not sure i did get this right.

beppe
Автор

Regular expressions is also a good subject to go over ;)

rthu
Автор

First view, comment, and like, anyway, awesome job explaining, thanks for the vid!

ayaanp
Автор

Generally switch is faster. To string a bunch of if else if's is slower but has a place for priority encoding.

rthu
Автор

You should explain the post, redirect, get pattern

andrewv
Автор

A switch is not always the same as an if statement.
Usually switch statements have different kind of optimizations in other languages and I'm assuming it's the case for golang aswell.
For example they work well in loops with numeric values for your switch cases because it can predict values.
I'm pulling this out of my ass judging from what I know from other languages, but I'm pretty sure this is standard optimization for switch statements in pretty much all programming languages.

razshare
Автор

Here we \go. One more tutorial. Good news

MaximRovinsky
Автор

Wait... we don't have to write "break" each of cases??

KangJangkrik
Автор

There is a difference between if-else and switch. Speed...

EnitinEnitin