What is shadowing

sebastian_cheung via scala-language <[email protected]>
Newsgroups gmane.comp.lang.scala
Message-ID <[email protected]>
Following Coursera and lecture example:

Why f is visible from within definition of 'result' and x is not?

Thanks

val x = 0

def f(y: Int) = y + 1

val result = {
  val x = f(3)  //f is externally defined
  x * x   // but x is internally defined, shadows the occurrence of the outer x
} + x

-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.