String message = "Error occurred!";
Boolean shouldNotifyUser = config.isNotificationEnabled();
if (shouldNotifyUser) {
notifyUser(currentUser, message);
}
val message = "Error occurred!"
val shouldNotifyUser = config.notificationEnabled
if (shouldNotifyUser) notifyUser(currentUser, message)
Semicolons are optional (read as not needed) in Scala.
Semicolons might be needed in some special situations, though there is always a way to avoid them. Besides, optional semicolons makes the transition of developers used to Java or other C-family of languages smoother.
Avoid using semicolons. I get nostalgic about them sometimes as well but it’s like reminiscing manual transmission in the age of self-driving cars. Don’t shift gears manually, let the auto transmission do it for you.
Compilers, like everything else, had many great breakthroughs since the C language appeared. A smart modern compiler can infer end of statements in most cases, with a little bit of help in all cases.