Kotlin Newbie To Pro - WHEN - Part 15

  Рет қаралды 19,156

Philipp Lackner

Philipp Lackner

Күн бұрын

Пікірлер: 60
@viktor-leskov
@viktor-leskov 4 жыл бұрын
When expression its most beautiful switch implementation i`ve ever seen
@younesscoder
@younesscoder Жыл бұрын
Thanks dude for the tutorial This is my solution: fun main() { val country = readLine()?.lowercase() when(country) { "india" -> println("Namaste") "usa" -> println("Hello") "russia" -> println("Privet") "germany" -> println("Hallo") else -> println("I don't know that") } }
@hobbesters7251
@hobbesters7251 3 жыл бұрын
props for making this on Christmas you are truly a legend.
@pranavchaturvedi2452
@pranavchaturvedi2452 3 жыл бұрын
Thanks for the tutorials man? Finished a playlist of yours in 2hrs 😊
@pavelmesicek
@pavelmesicek 3 жыл бұрын
Are u sure that it is a good way how to learn programming? I do not think so...
@pranavchaturvedi2452
@pranavchaturvedi2452 3 жыл бұрын
@@pavelmesicek after learning basic kotlin I jumped into projects though
@User-unknown_321
@User-unknown_321 8 ай бұрын
​@pranavchaturvedi2452 what kinda progress you did after this series! It'll be so helpfull
@toystoryscarymovie-forkids3323
@toystoryscarymovie-forkids3323 Жыл бұрын
thank you phillip but i believe the last question didnt reflect the assumption that the values 0 and 1 already existed in the list. it suggests an empty list question where entering a number >1 is the only input to the list
@HarshSingh-b6v
@HarshSingh-b6v 10 ай бұрын
fun main(){ println("where you are from") var x= readln().toString() when(x){ in "india" -> println("namaste") in "usa"-> println("hello") in "japan"-> println("konichiwa") in "germany"-> println("hallo") in "france"-> println("bonjour") in "russia"-> println("privet") } }
@ck.8632
@ck.8632 3 жыл бұрын
Dzień Dobry is the way to say hello in Polish :D
@vathsan3906
@vathsan3906 4 жыл бұрын
Vanakkam! Love from India! A bit of gen knowledge: Hindi is spoken only by 40% of Indians. India has 22 official languages. Thanks a lot for these awesome tutorials.. I'm loving it!!!!!!!!!!
@surajgiri3156
@surajgiri3156 4 жыл бұрын
fun main() { println("Where are you from") when (readLine()) { "India" -> println("Namaste") "USA" -> println("Hello") "Germany" -> println("Hallo") "Russia" -> println("privet") else -> println("I don't know that") } }
@AmjadxDev
@AmjadxDev 17 күн бұрын
Thank you #Philipp you are right my basics concept are not clear i start you tutorial from scrach. sorry for misbehave
@DeathlabelCSS
@DeathlabelCSS 6 ай бұрын
fun main() { println("Where are you from?") var loc = readln() when(loc){ "USA", "UK" -> println("Hello") "Russia" -> println("Privet") "Germany" -> println("Hallo") "India" -> println("Namaste") else -> println("I don't know that") } }
@Twishma
@Twishma 17 күн бұрын
fun main() { println("PLease Enter A Country Name: ") val greeting = readlnOrNull() when(greeting) { "Kenya" -> println("Mambo") "German" -> println("Guten Tag") "France" -> println("Bonjour") "Italy" -> println("Ciao") "Spain" -> println("Hola") "India" -> println("Namaste") else -> println("Enter one of the areas given please") } }
@jasonbraithwaite9204
@jasonbraithwaite9204 4 жыл бұрын
Excellent tutorials thank you 👍
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Always welcome! :)
@willianrodrigohuber7968
@willianrodrigohuber7968 Жыл бұрын
Thanks for this video, my answer for this homework stay bellow. I don't know it is the best answer, but a cant do it in this form fun main() { println("Where are you from?") val country = readlnOrNull() country?.let { country -> sayHello(country.lowercase()) } } fun sayHello(country: String) { when(country) { "india" -> println("Namaste") "usa" -> println("Hello") "germany" -> println("Hallo") "russia" -> println("Privet") else -> println("I don't know that") } }
@ekafrancium
@ekafrancium Жыл бұрын
fun main() { println("enter your country: ") val input = readLine() if (input!=null){ when(input){ "India" -> println("namaste") "USA" -> println("Hello") "Russia" -> println("privert") "Germany" -> println("hallo") else -> println("I don't know") } } }
@ashleymudambaji2608
@ashleymudambaji2608 Жыл бұрын
//Question1 println("Enter 5 numbers:") val numberList = mutableListOf() for (j in 1..5){ val number = readln().toInt() numberList.add(number) } println("The numbers are now: $numberList") println("The numbers when reversed are: ${numberList.asReversed()} ")
@VijayRaj-pw2px
@VijayRaj-pw2px Жыл бұрын
fun main() { // when list of user entered countries and greeting println("Where are you from?") val country = readLine() when(country) { "India", "india" -> println("Namaste") "USA", "America", "usa", "america", "United States of America" -> println("Hello") "Germany", "germany" -> println("Hallo") "Russia", "russia" -> println("Privet") else -> println("I don't know that") } }
@ihorgrey23
@ihorgrey23 2 жыл бұрын
fun main() { println("Where you from ?") val national = readln() when (national) { "USA" -> println("Hey!") "Germany"-> println("Hallo!") "India" -> println("Namaste!") "Russia" -> println("Privet!") } }
@MANNUKUMAR-dj4us
@MANNUKUMAR-dj4us Жыл бұрын
best tutor 🤠
@userglls
@userglls 11 ай бұрын
%100. have you finished the playlist ?
@patilpatade
@patilpatade Ай бұрын
fun main(){ println("Where Are you from ? ") val country= readLine().toString().lowercase() when(country){ "india" -> println("Namaste!") "pakistan" -> println("Salam Waleku") "usa" -> println("Hello") "germany" -> println("Hallo") else -> println("Sorry dont have any idea about your country") } }
@nicolasvantsis6166
@nicolasvantsis6166 4 жыл бұрын
Hi, for the solution of the first exercise maybe it's easier to do this: println("The 5 numbers in reverse order are:") for (item in list.reversed()) { println(item) } Because we saw this method in the previous video.
@PhilippLackner
@PhilippLackner 4 жыл бұрын
That's easier, but less performant because you need to reverse the whole list and then print it. In my example we only print it because the index starts at the last number and goes down. But this series is not about performance, so your solution is perfectly fine, good job 👍
@nicolasvantsis6166
@nicolasvantsis6166 4 жыл бұрын
@@PhilippLackner Ok, thanks. For me it's better to learn the best solution (the one that gives the optimal performance) from the beginning.
@md.minhaz3878
@md.minhaz3878 3 жыл бұрын
Thanks for your helpful class. I am from Bangladesh..
@PhilippLackner
@PhilippLackner 3 жыл бұрын
You are most welcome
@paulvickers8059
@paulvickers8059 3 жыл бұрын
fun main() { println("Where are you from?") val result = when(readLine()) { "India" -> "Namaste" "USA" -> "Hello" "Germany" -> "Hallo" "Russia" -> "Privet" else -> "I don't know that" } print(result) }
@arunmk8349
@arunmk8349 2 ай бұрын
fun main() { println("Enter your country name,please") var String = readLine() when(String){ "India" -> println("Namasthe") "USA" -> println("Hello") "Spain" -> println("Hola") "Russia" -> println("Privet") else-> println("I don't know") } }
@ruhiyatrp6359
@ruhiyatrp6359 4 жыл бұрын
thank you Philipp, i really love your tutorial, it very simple to understand... //Homework 1 println("Where are you from ?") val country = readLine() val x = country?.toUpperCase() when (x) { "INDIA" -> println("Namaste") "USA","GERMANY" -> println("Hallo") "RUSIA" -> println("Privet") else -> println("I don't know that") }
@codesbyabgolor
@codesbyabgolor Ай бұрын
println("Where are you from?") val country = readLine() if(country != null) when(country){ "India" -> println("namaste") "USA" -> println("Hello") "Germany" -> println("Hallo") "Russia" -> println("Privet") "Nigeria" -> println("Hafa") else -> println("I don't know that") }
@ИльяГущин-с4м
@ИльяГущин-с4м 4 жыл бұрын
Privet! I'm from Russia, thanks for tutorials 👍
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Always welcome! :)
@userglls
@userglls 11 ай бұрын
fun main() { // Homework println("Where are you from? ") val userInput = readLine() when (userInput) { "USA" -> println("What up boy") "India" -> println("Namaste") "TKM" -> println("Salam") "Turkey" -> println("Naber") "Russia" -> println("Privet") else -> println("You're an Alien") } }
@kalios01
@kalios01 Жыл бұрын
It is similar to switch case 😅
@CezaryOdwazny
@CezaryOdwazny Жыл бұрын
Dzień dobry form Poland
@spacegyaan2171
@spacegyaan2171 3 жыл бұрын
Thank You ❤
@suimishaikh2908
@suimishaikh2908 Жыл бұрын
println("Where are you from?") val country = readln() when(country){ "India" -> println("Namaste") "Usa" -> println("Hello") "Germany" -> println("Hallo") "Russia" -> println("Privet") else -> println("I don't know that") }
@bogite8734
@bogite8734 Жыл бұрын
fun main () { val location = readLine() if (location != null) { when(location) { "India" -> println("Namaste") "USA" -> println("Hello") "Germany" -> println("Hallo") "Russia" -> println("Privet") else -> println("I don't know that") } } } Homework
@moneyharry
@moneyharry 2 жыл бұрын
this is called switch-case in many other programming language
@piyushinsightss
@piyushinsightss 2 жыл бұрын
namaste from india😁
@aayushsao3302
@aayushsao3302 3 жыл бұрын
Namaste🙏
@Ilamarea
@Ilamarea 2 жыл бұрын
You can use boolean conditionals and other variables with a when statement, but then you need to repeat the variable: when{ age > x || age in 5..17 -> println(" ") age == 18 -> println(" ") age in 19..20 -> println(" ") } The important note is that the when statement will execute only one of the expressions and it will always be the first that matches the condition.
@itamarribeiro8865
@itamarribeiro8865 4 жыл бұрын
fun greet() { println("Where are you from?") val place = readLine()?.toLowerCase() when (place) { "usa" -> println("Hello") "germany" -> println("Hallo") "russia" -> println("privet") "india" -> println("Namaste") else -> println("I don't know that") } }
@ajinkyakumbhar595
@ajinkyakumbhar595 4 жыл бұрын
It's like switch case in java 😅😅
@PhilippLackner
@PhilippLackner 4 жыл бұрын
yes very similar, but not the same :D
@idiomz4104
@idiomz4104 2 жыл бұрын
12:15 Press F for Polish people
@Jonathan1Brito
@Jonathan1Brito Жыл бұрын
val country:String? = readLine()?.toString() when (country) { "Brazil" -> println("Oi") "USA" -> println("Hello") "Spain" -> println("Hola") "Russia" -> println("Privet") "Germany" -> println("Hallo") else -> println("I do not know") }
@maazakbar3399
@maazakbar3399 Жыл бұрын
Hi Frist of all thankyou so much for this koltin course your all teturail is very helpful of beginners this is my "where are you form" Task fun main() { print("what is your name: ") var x = readLine() print("where are you from ") var country= readLine() when(country) { "pakistan"-> print("Aslamualikom: Mr.$x") "UAE"-> print("Hello: Mr.$x") "India"-> print("Namasti: Mr.$x") "canada"-> print("Hi: Mr.$x") "japan "-> print("Konnichiwa: Mr.$x") "Azarbhijan"-> print("salam: Mr.$x") "KSA"-> print("Aslamualikom: Mr.$x") "Dubai"-> print("Hello: Mr.$x") "portugal"-> print("Hi: Mr.$x") "Afghanistan"-> print("Assalamualaikum: Mr.$x") "Australia"-> print("Hello: Mr.$x") "zambwabi"-> print("Hi: Mr.$x") } }
@gamermom1945
@gamermom1945 2 жыл бұрын
val age = readLine()?.toInt() var message: String = "" message = when(age) { in 0..5 -> "You're a younh kid" in 6..17 -> "You're a teenager" 18 -> "You're 18! Gratz!" 19, 20 -> "You're a young adult" in 21..65 -> "You're an adult" else -> "You're really old" } println(message)
Kotlin Newbie To Pro - FUNCTIONS AND PARAMETERS - Part 16
13:12
Philipp Lackner
Рет қаралды 19 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 99 М.
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Kotlin Newbie to Pro - CLASSES - Part 20
18:38
Philipp Lackner
Рет қаралды 23 М.
Kotlin Newbie To Pro - LISTS - Part 14
14:28
Philipp Lackner
Рет қаралды 23 М.
Kotlin Newbie To Pro - FOR LOOP - Part 13
12:43
Philipp Lackner
Рет қаралды 20 М.
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,8 МЛН
Kotlin Newbie To Pro - VARARG, DEFAULT AND NAMED PARAMETERS -  Part 18
15:11
Learn Kotlin in 12 Minutes
12:01
Rahul Pandey
Рет қаралды 352 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 344 М.
Kotlin Newbie to Pro - LAMBDA FUNCTIONS - Part 28
16:29
Philipp Lackner
Рет қаралды 35 М.
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН