In Ruby, how do I check if method “foo=()” is defined?
The problem is that the foo= method is designed to be used in assignments. You can use defined? in the following way to see what’s going on: defined?(self.foo=()) #=> nil defined?(self.foo = “bar”) #=> nil def foo=(bar) end defined?(self.foo=()) #=> “assignment” defined?(self.foo = “bar”) #=> “assignment” Compare that to: def foo end defined?(foo) #=> “method” … Read more