Skip to content

Instantly share code, notes, and snippets.

@namusyaka
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namusyaka/2652d0ce30b32870f376 to your computer and use it in GitHub Desktop.
Save namusyaka/2652d0ce30b32870f376 to your computer and use it in GitHub Desktop.
class A
attr_writer :foo
def test(k)
[respond_to?(:"#{k}="), respond_to?("#{k}=")]
end
end
a = A.new
p a.respond_to?(:test) #=> true
p a.respond_to?("test") #=> true
p a.test(:foo) #=> [false, true]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment