When expression its most beautiful switch implementation i`ve ever seen
@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") } }
@hobbesters72513 жыл бұрын
props for making this on Christmas you are truly a legend.
@pranavchaturvedi24523 жыл бұрын
Thanks for the tutorials man? Finished a playlist of yours in 2hrs 😊
@pavelmesicek3 жыл бұрын
Are u sure that it is a good way how to learn programming? I do not think so...
@pranavchaturvedi24523 жыл бұрын
@@pavelmesicek after learning basic kotlin I jumped into projects though
@User-unknown_3218 ай бұрын
@pranavchaturvedi2452 what kinda progress you did after this series! It'll be so helpfull
@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-b6v10 ай бұрын
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.86323 жыл бұрын
Dzień Dobry is the way to say hello in Polish :D
@vathsan39064 жыл бұрын
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!!!!!!!!!!
@surajgiri31564 жыл бұрын
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") } }
@AmjadxDev17 күн бұрын
Thank you #Philipp you are right my basics concept are not clear i start you tutorial from scrach. sorry for misbehave
@DeathlabelCSS6 ай бұрын
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") } }
@Twishma17 күн бұрын
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") } }
@jasonbraithwaite92044 жыл бұрын
Excellent tutorials thank you 👍
@PhilippLackner4 жыл бұрын
Always welcome! :)
@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 Жыл бұрын
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 Жыл бұрын
//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 Жыл бұрын
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") } }
@ihorgrey232 жыл бұрын
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 Жыл бұрын
best tutor 🤠
@userglls11 ай бұрын
%100. have you finished the playlist ?
@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") } }
@nicolasvantsis61664 жыл бұрын
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.
@PhilippLackner4 жыл бұрын
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 👍
@nicolasvantsis61664 жыл бұрын
@@PhilippLackner Ok, thanks. For me it's better to learn the best solution (the one that gives the optimal performance) from the beginning.
@md.minhaz38783 жыл бұрын
Thanks for your helpful class. I am from Bangladesh..
@PhilippLackner3 жыл бұрын
You are most welcome
@paulvickers80593 жыл бұрын
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) }
@arunmk83492 ай бұрын
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") } }
@ruhiyatrp63594 жыл бұрын
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Ай бұрын
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 жыл бұрын
Privet! I'm from Russia, thanks for tutorials 👍
@PhilippLackner4 жыл бұрын
Always welcome! :)
@userglls11 ай бұрын
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 Жыл бұрын
It is similar to switch case 😅
@CezaryOdwazny Жыл бұрын
Dzień dobry form Poland
@spacegyaan21713 жыл бұрын
Thank You ❤
@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 Жыл бұрын
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
@moneyharry2 жыл бұрын
this is called switch-case in many other programming language
@piyushinsightss2 жыл бұрын
namaste from india😁
@aayushsao33023 жыл бұрын
Namaste🙏
@Ilamarea2 жыл бұрын
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.
@itamarribeiro88654 жыл бұрын
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") } }
@ajinkyakumbhar5954 жыл бұрын
It's like switch case in java 😅😅
@PhilippLackner4 жыл бұрын
yes very similar, but not the same :D
@idiomz41042 жыл бұрын
12:15 Press F for Polish people
@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 Жыл бұрын
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") } }
@gamermom19452 жыл бұрын
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)