Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created December 7, 2013 19:27
Show Gist options
  • Select an option

  • Save v6ak/7847356 to your computer and use it in GitHub Desktop.

Select an option

Save v6ak/7847356 to your computer and use it in GitHub Desktop.
// Mohli bychom se hádat, jestli tato funkce mění stav, ale referenčně transparentní rozhodně není:
def f = new java.io.File("/tmp").exists
// Tato funkce nemění stav, ale referenčně transparentní není:
def g(x: String) = new java.io.File(x).exists
object Foo{
var invocationCount: Int = 0
def h(x: Int){
invocationCount += 1
// A jdeme do extrému: Tato funkce teoreticky mění stav, ale jde o naprosto neužitečný stav, takže je RT.
x+1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment