Skip to content

Instantly share code, notes, and snippets.

@rtfpessoa
Last active October 6, 2015 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtfpessoa/ce8e7007ee54e6366474 to your computer and use it in GitHub Desktop.
Save rtfpessoa/ce8e7007ee54e6366474 to your computer and use it in GitHub Desktop.
Scala can be weirdly dangerous
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