Created
December 7, 2013 19:27
-
-
Save v6ak/7847356 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // 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