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

Represent a TaskArgument object such that it's not confused with a hash. #171

Merged
merged 1 commit into from
Oct 26, 2016

Conversation

aquateen
Copy link
Contributor

ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])

Currently

puts ta # {:a=>1, :b=>2, :c=>3}

Proposal

puts ta # #<Rake::TaskArguments a: 1, b: 2, c: 3>

Why?

The current implementation leads one to believe they are working with a hash. This can lead to some confusion if you try doing something like ta.a = 'one' which will silently ignore the assignment.

In addition, I think def_method is preferable to method_missing to create accessors. That way ta.a = 'one' would generate a NoMethodError. Thoughts?

Shoutout to @eric-hu, with whom I discovered this issue.

@hsbt
Copy link
Member

hsbt commented Oct 26, 2016

👍 I prefer this inspection message. Thanks!

@hsbt hsbt merged commit ea67f73 into ruby:master Oct 26, 2016
er0ck pushed a commit to er0ck/rototiller that referenced this pull request Apr 11, 2017
* acceptance previously showed a bug we had against rake 12
* really rake 12 just clarified how to use arguments to tasks so they
aren't confused with hashes: ruby/rake#171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants