Skip to content
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

make Literal::Array#push accept multiple values #141

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

phillipspc
Copy link
Contributor

@phillipspc phillipspc commented Nov 11, 2024

Related to #134


The current implementation of #push was only allowing for one value to
be passed in, but if the goal is to match ruby's functionality, then it
should accept multiple.

We also want to ensure that we perform the right type checking logic for
both scenarios.

@phillipspc phillipspc marked this pull request as draft November 11, 2024 02:25
The current implementation of `#push` was only allowing for one value to
be passed in, but if the goal is to match ruby's functionality, then it
should accept multiple.

We also want to ensure that we perform the right type checking logic for
both scenarios.
While we're here, let's add the `#append` method alias.
@phillipspc phillipspc marked this pull request as ready for review November 11, 2024 02:34
def push(*value)
case value
when ::Array
Literal::Array(@__type__).new(*value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed like the best way of forcing the type check to happen on an array of values. But 🤷‍♂️

@joeldrapper joeldrapper merged commit ce97bd6 into joeldrapper:main Nov 11, 2024
10 checks passed
@stevegeek
Copy link
Collaborator

Thanks @phillipspc !

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.

3 participants