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.