Skip to content

Define respond_to_missing? when overriding method_missing#118

Open
brandonc wants to merge 1 commit intoattachmentsme:masterfrom
brandonc:method_missing_respond_to_missing
Open

Define respond_to_missing? when overriding method_missing#118
brandonc wants to merge 1 commit intoattachmentsme:masterfrom
brandonc:method_missing_respond_to_missing

Conversation

@brandonc
Copy link

When an object responds to a method but says that it doesn't, it can
lead to unexpected behavior. See this article https://robots.thoughtbot.com/always-define-respond-to-missing-when-overriding

> item.id
> "12345"
> item.try(:id)
> nil
> item.respond_to?(:id)
> false

When an object responds to a method but says that it doesn't, it can
lead to unexpected behavior.

```
> item.id
> "12345"
> item.try(:id)
> nil
> item.respond_to?(:id)
> false
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant