Domanda

In specs bdd framework(http://code.google.com/p/specs), i can check if a value is assigned to a string or not using :

SomeClass.strVal == null mustBe false

Now, suppose the class has a boolean value boolVal. How to check if a value true or false was assigned to boolVal or not ?

Please Help Thanks

È stato utile?

Soluzione

Acccording to this page, the Boolean class derives from AnyVal. Therefore boolean is a value type and no boolean variable can be null. In fact, since Scala runs atop the java pplatform, it probably has the default value of false

In general, it is not good practice to leave variable uninitialized. When a variable is declared, give it a value. This alleviates the need to do these kinds of checks.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top