-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScalaClassTest.scala
53 lines (37 loc) · 1.25 KB
/
ScalaClassTest.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.training
class ScalaClassTest {
def invokeClass(): Unit = {
println("Invoked ScalaClassTest....")
var a=9
//while loop
// while(a<10){ //Relational Operators
// println("while loop a=>"+ a)
// a = a + 1 //Arithmetic operator
// }
//do while
// do{
// println("do while loop a=>"+ a)
// a = a + 1 //Arithmetic operator
// }while(a<=12)
// for loop with collection
val numList = List(6,7,8)
// for ( b <- numList ){
// println("for loop b=>"+ b)
// }
// var lastValue = for {
// c <- numList
// if c != 7
// } yield c
//
// println("yield value lastValue=>"+ lastValue)
// val colors = Map("red" -> "#FF0000", "azure" -> "#F0FFFF", "peru" -> "#CD853F")
// colors.keys.foreach{ i =>
// print( "Map Key = " + i )
// println(" Value = " + colors(i) )
// }
//tuple can hold objects with different types
// val t = (4,"tuple",2.0,true)
// t.productIterator.foreach{
// i =>println("tuple Value = " + i )}
}
}