Herfan Heryandi
Herfan Heryandi

Reputation: 19

How to define variable in play scala template

I want to define this Java variable

int x = 0; 
x = x + 1;

How is it in Play Scala Template??

I already tried this for defining:

@import scala.Predef;
val x= 0

but I can't add the variable

Upvotes: 0

Views: 2282

Answers (1)

Feyyaz
Feyyaz

Reputation: 3206

They should be on the same line

@import scala.Predef; val x= 0

Also, if it is a variable, you should use var not val.

So what you need is

@import scala.Predef; var x= 0

And for reassigning:

@(x = x + 1)

Upvotes: 1

Related Questions