Programming in Kotlin - Part 41: Challenge: Lambdas | Ray Wenderlich

Practice using Lambdas through a hands-on challenge.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4736-programming-in-kotlin/lessons/41

Wrong Starter project. On the video at 0:23 shows what the Starter should look like, but the list and the class are missing.

Again no Audio during coding. Plus the last part didn’t even use lambda, however it could have been solved by a .forEach{}

@fr3qfly The instructor doesn’t talk while typing but explains the code afterwards.

@shogunkaramazov that’s not what I meant. For me the video goes silent once the coding screen comes up. And it stays silent till the end. If I go back before the coding screen came up the audio is back. I am using Safari. I tried it in Firefox and I think I know what can be the problem. In Firefox I can hear the commentary during the coding, however only on one ear (I am using earphones :slight_smile: ) It seams there is some mix-up of the Audio Channels in the video file.

@fr3qfly The video works in Safari without issues for me. Have you tried Chrome as well?

No, I don’t have Chrome, but I tried on a different computer. In Safari it works fine (still only the Left Audio channel has sound) I am not sure (it was yesterday late evening), but maybe only the right earphone was in my ears, and I didn’t check the left. :sweat_smile:

@kevindmoore
Oh my god. Again the material issue on this course(this is a 3rd).
Please compare uploaded material with the video. There is no given list, no given Person class, no given map.
I really disappointed to this course.

@kevindmoore Can you please help with this when you get a chance? Thank you - much appreciated! :]

Exercise files should now be updated

Hello, the solution used for summation of list does not work for me. It gives me an error on sum() saying unresolved reference . How do I fix this ?
image
Thanks

I did fix this error by moving methods outside main, but I still dont understand why it happened in the first place.

I went and took another look at the project and don’t see a problem. It should work inside of the main function. Both filter and sum are part of the _Collections.kt file (part of Kotlin standard library).
Are you using the latest Intellij with the Kotlin plugin installed?

Thanks @kevindmoore. I am using intellij Ultimate 2019 edition and Kotlin 1.3.21.
I knew this error should not have been there, so I tried working in a new file and it worked.

And in previous file I moved methods outside main and then it worked, but then I moved the methods again inside and then it dint show the error.
Still no clue why the error was there.

@henna_dev Do you still have issues with this?

1 Like

Thanks @shogunkaramazov, it has been resolved. =)

I don’t understand what the 2nd and 3rd exercises in the example project have to do with what we just learned about lambdas. Destructuring and map iteration were covered earlier in the series and don’t use lambda functions in the solutions.

You are right, the 2nd & 3rd example don’t fit the challenge. Here’s a different answer for the 3rd example:
val names = mapOf<String, Int>(“John” to 34, “Fred” to 24, “Sam” to 30, “Suzzy” to 29)
names.map { entry -> println("${entry.key} is ${entry.value} years old ") }