Scala not found: value x when unpacking returned tuple -


i've seen kind of code on countless websites yet doesn't seem compile:

def foo(): (int, int) = {         (1, 2) }  def main(args: array[string]): unit = {         val (i, o) = foo() } 

it fails on marked line, reporting:

  • not found: value i
  • not found: value o

what might cause of this?

the problem use of upper case letters i , o in pattern match. should try replace lowercase letters val (i, o) = foo(). scala language specification states value definition can expanded pattern match. example definition val x :: xs = mylist expands following (cf. p. 39):

val x$ = mylist match { case x :: xs => {x, xs} } val x = x$._1 val xs = x$._2 

in case, value definition val (i, o) = foo() expanded in similar way. however, language specification states, pattern match contains lower case letters (cf. p. 114):

a variable pattern x simple identiļ¬er starts lower case letter.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -