Sensible Warnings

Getting ahead of errors

Even if a piece of code is valid syntactically, some potential problems may be lurking. Getting an early warning, during compilation time, can help us to proactively fix such possible issues. The Kotlin compiler looks out for quite a few potential issues in code.

For example, if a parameter that’s received in a function or a method isn’t used, then the compiler will give a warning. In the following script, the parameter passed to compute() isn’t used.

Get hands-on with 1200+ tech skills courses.