October 2019
Intermediate to advanced
434 pages
11h 54m
English
It's also completely possible to check for null using standard conditional if/else checks. In this snippet, if args is null, the expression will evaluate to 0:
fun parseArgs(args: Array<String>?) { val argCount = if(args != null) args.size else 0}
This type of if/else expression makes working with val much easier as we can ensure our variable values are assigned only once, adding to the level of immutability within our programs.
Read now
Unlock full access