Skip to content

Commit 6865659

Browse files
authored
Update Employee.scala
Added comments about Excetions and Require
1 parent 50762b1 commit 6865659

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

4.Classes-Objects/Employee.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import scala.beans.BeanProperty
77
*
88
* call another constructor by invoking this
99
*
10+
* Scala does not have Checked Exceptions. All Exceptions are unchecked in scala, even SQLException and IOException
11+
*
1012
*/
1113
class Employee (@BeanProperty val firstName:String, @BeanProperty var lastName:String, @BeanProperty val title:String) //This is default constructor
1214
{
13-
require(firstName.nonEmpty, "First Name cannot be empty!!") //preconditions using require
15+
require(firstName.nonEmpty, "First Name cannot be empty!!") //preconditions using require. If not met, will throw IllegalArgumentException
1416
require(lastName.nonEmpty, "Last Name cannot be empty!!")
1517
require(title.nonEmpty, "Title cannot be empty!!")
1618

0 commit comments

Comments
 (0)