I am a newbie in Scala. I was trying to use a if-else block in scala to try and return a "Int".
My code looks something likie this:
val blockNumber = {
if(x.getName equals ("NATIVE")) 0
else {
if(x.getName equals ("DATIVE")) 1
}
}
I use this value blockNumber in the method setBlockNumber() and this where the problem occurs:
new setBlockNumber(Option(blockNumber))
But everytime I try to do this the method gives an error saying :
type mismatch; found : AnyVal required: Int
Can somebody please point out my mistake and how can I rectiy it? Thankyou for your time in advance.
Aucun commentaire:
Enregistrer un commentaire