The Kotlin type system helps us to avoid NullPointerException errors in our code. In this video, learn how to use the Let function, safe-call operator, and non-null assertions to safely handle nullable values.
- [Instructor] Now let's take a look…at nullability in Kotlin.…This is what helps us to avoid…null pointer exception errors in our code.…So we're here inside of the nullability file,…in the test folder.…Now as you can see, we have several test methods…that we're going to fill in,…which will help us to better understand…how the Kotlin language protects us from nulls in our code.…So the first thing we're going to do…is create a function called double string…that would duplicate a string's contents here on line five.…So just as usual, we start with the fun keyword,…it's going to be called doubleString,…we're going to pass in a string for the parameter,…and we're going to return another string,…which is the same one doubled.…
So this is just going to be the string that we receive,…and then we'll use the repeat function…from the Kotlin standard library…and we'll supply the number two because we want it twice.…Now notice that when we declare our string parameter,…we don't have a question mark after the type.…This means that whatever value we pass…
- What Kotlin has to offer
- Working with lambdas
- Common Android extension functions
- Kotlin Android Extensions overview
- Making use of the Anko library
- Working with coroutines
- Nullability and collections
Skill Level Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis3h 59m Intermediate
Developing AWS Lambda Functions with Kotlinwith Troy Miles1h 55m Intermediate
1. Kotlin Overview
2. Extension Functions and Properties
3. Incorporating Anko
4. Advanced Anko
5. Working with Collections
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.