Created
March 22, 2012 15:57
-
-
Save jbarnette/2159171 to your computer and use it in GitHub Desktop.
Incredibly stupid Ruby tricks. Please add more.
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
# The worst possible way to memoize something. | |
class X | |
def value | |
@value = really_expensive_operation | |
def value; @value end | |
@value | |
end | |
end |
But that's an awesome way to memoize…
@rkh Yeah! That may even have been where I've seen it recently.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tilt actually does this.