New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve docs #265
Improve docs #265
Conversation
`RuboCop::ProcessedSource` is from `rubocop`.
* it will match `sum(2.0, 3)`, as the first argument is of a `float` type | ||
* it will not match `sum(2, 3)`, as the first argument is of an `int` type | ||
|
||
NOTE: Negation operator works with other node pattern syntax elements, `{}`, `[]`, `()`, `$`, but not with `<>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uncertain if this is intentional.
(send nil? :foo <int ...>)
would work to match a foo
call with at least one integer literal.
(send nil? :foo !<int ...>)
would not work to match a foo
call with no literal integer arguments. Is there a more canonical way to achieve that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's more complex than that. You can negate a pattern that targets a single element (e.g. !{int | sym}
) but not other pattern (e.g. !{int int | sym sym}
).
Not sure why you wrote it doesn't work with $
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
I understand that with variable number of elements like {int | sym sym}
and <int ...>
it's an easily justifiable behaviour.
I guess (send _ !<true false>)
is more tricky due to the hidden number of elements ambiguity? It seems like it would match if there are no arguments (foo()
), a single non-boolean argument (foo(1)
), and multiple arguments as well, which just would open space for more confusion.
Not sure why you wrote it doesn't work with
$
Because I didn't! 😄
Thanks for the clarification! I've updated this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for improving the docs. I have a few comments
* it will match `sum(2.0, 3)`, as the first argument is of a `float` type | ||
* it will not match `sum(2, 3)`, as the first argument is of an `int` type | ||
|
||
NOTE: Negation operator works with other node pattern syntax elements, `{}`, `[]`, `()`, `$`, but not with `<>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's more complex than that. You can negate a pattern that targets a single element (e.g. !{int | sym}
) but not other pattern (e.g. !{int int | sym sym}
).
Not sure why you wrote it doesn't work with $
1788b18
to
e2a6fa5
Compare
Without `--legacy`, it would return `kwargs`, not `hash`: (send (const nil :Comment) :new (kwargs (pair (sym :user) (send nil :current_user))))
075a1f2
to
02d78f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thank you
This:
fixes #228