Conditional checks

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.