1

So I have this code (all of this is in the one scala.html file):

@getLevelAsRoman(level: Integer) : String = @{
 @if(level == 1){ 
    @return "I"
 }
 @if(level == 2){ 
    @return "II"
 }
 @if(level == 3){ 
    @return "III"
 }
} 

And I call it like this:

@{move.getMove.getName + " " + getLevelAsRoman(move.getMoveLevel) }

I just want to show the value in my html. How am I meant to do this? The above code gets the error

identifier expected but 'if' found.
halfer
  • 18,701
  • 13
  • 79
  • 158
bharal
  • 14,067
  • 31
  • 108
  • 182

1 Answers1

0

I would try:

@getLevelAsRoman(level: Integer): String = @{  
    if(level == 1){ 
        "I"
    } else if(level == 2){ 
        "II"
    } else if(level == 3){ 
        "III"
    } else {
        "default"
    }
}
DrKaoliN
  • 1,266
  • 3
  • 26
  • 36