Declare a global variable in scala -


is possible declare global variable in way?

if run snippet, encounter error

object test {   val value -> error on line declaration issue   def run() {     value  = ...    } def main(args: array[string]) {     run()   } 

thanks in advance.

you in theory using trait. i'm not sure need though.

it this:

trait mytesttrait {   val value: string }  object mytest extends mytesttrait {   val value = "yo!"   def run = println(value) } 

Comments