'||' and '&&' are Short circuit Operators #126
scala> def math():Boolean = {
| println("Math -> False")
| false
| }
math: ()Boolean
scala> def science():Boolean = {
| println("Science -> True")
| true
| }
science: ()Boolean
scala>
scala> println("Case 1")
Case 1
scala> //Note here only math() is evaluated
scala> //ie... the evaluation for science() is declined
scala> //This is achieved through the facility for Methods(in our case &&)
scala> //called by-name parameters
scala> val res = math() && science()
Math -> False
res: Boolean = false
scala>
scala> println("Case 2")
Case 2
scala> //Note here both math() & science are evaluated
scala> val res = science() && math()
Science -> True
Math -> False
res: Boolean = false