Skip to content

Instantly share code, notes, and snippets.

@Papierkorb
Created August 20, 2015 15:54
Show Gist options
  • Save Papierkorb/ede1c553c73c191063f8 to your computer and use it in GitHub Desktop.
Save Papierkorb/ede1c553c73c191063f8 to your computer and use it in GitHub Desktop.
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