Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jbarnette
Created March 22, 2012 15:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbarnette/2159171 to your computer and use it in GitHub Desktop.
Save jbarnette/2159171 to your computer and use it in GitHub Desktop.
Incredibly stupid Ruby tricks. Please add more.
# The worst possible way to memoize something.
class X
def value
@value = really_expensive_operation
def value; @value end
@value
end
end
@rkh
Copy link

rkh commented Mar 22, 2012

Tilt actually does this.

@rue
Copy link

rue commented Mar 22, 2012

But that's an awesome way to memoize…

@jbarnette
Copy link
Author

@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