Skip to content

Instantly share code, notes, and snippets.

@nagachika
Last active March 13, 2019 14:29
Show Gist options
  • Save nagachika/2ac5d7090c02e6a7fb2114f9b146e9b5 to your computer and use it in GitHub Desktop.
Save nagachika/2ac5d7090c02e6a7fb2114f9b146e9b5 to your computer and use it in GitHub Desktop.
class A
DefConst = lambda{|x| Const = x }
def foo(x)
DefConst.call(x)
end
end
p(defined?(A::Const)) # => nil
A.new.foo(42)
p(defined?(A::Const)) # => "constant"
p(A::Const) # => 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment