I am new to Kotlin. I want to know the difference between this two !!
and ?
in below code.
Below, there are two snippets: the first uses
In Addition to what Alexander said and as shown in the docs too,
the ?.
safe call operator is very useful in chaining, something like this
student?.department?.hod?.name
if there is no student, returns null otherwise look for his department. If department doesn't exist returns null otherwise look for hod (head of department) and so on.
If any one of student, department or hod is null then the result will be null.