Last active
October 6, 2015 13:24
-
-
Save rtfpessoa/ce8e7007ee54e6366474 to your computer and use it in GitHub Desktop.
Scala can be weirdly dangerous
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object NameReDef { | |
def withWrapper(foo: String => String) = { | |
println("Wrapping ...") | |
foo("My pretty string") | |
} | |
def bar = { | |
withWrapper { str => | |
// Does not compile if we use the str above before the re-definition | |
// println("Defined:") | |
// println(str) | |
// Re-definition compiles if we do not use the str above | |
val str = "This is not my pretty string!!!" | |
println("Re-Defined:") | |
println(str) | |
str | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment