Type annotations

If you use a val or var keyword to declare a variable, its data type will be inferred automatically according to the value that you assigned to this variable. You also have the luxury of explicitly stating the data type of the variable at declaration time.

val myVal : Integer = 10

Now, let's look at some other aspects that will be needed while working with variables and data types in Scala. We will see how to work with type ascription and lazy variables.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.125.169