-
-
Save Papierkorb/ede1c553c73c191063f8 to your computer and use it in GitHub Desktop.
This file contains 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
class Cacher | |
def initialize | |
@cache = {} | |
end | |
def expensive(a) | |
"Foobar: #{a}" | |
end | |
def cached(selector) | |
# If using parantheses it would work: | |
# @cache['bla'] ||= expensive(selector) | |
# The following breaks with Opal: | |
@cache['bla'] ||= expensive selector | |
end | |
end | |
cache = Cacher.new | |
puts cache.cached('foo').inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment