Misc #16802
closed
Prefer use of RHS assigment in documentation
Added by ioquatix (Samuel Williams) over 4 years ago.
Updated over 4 years ago.
Description
Many documentation uses some format like this:
Hash.new -> hash
Now that RHS assignment is a thing, we can make the documentation valid Ruby code:
Hash.new => hash
There is some discussion here: https://github.com/ruby/ruby/pull/3026
I would like to start changing the existing documentation to use this, and in addition, make an automated sweep of the entire code base to update to the new syntax.
- Assignee set to ioquatix (Samuel Williams)
I'm not sure it's a good idea. There's some value in distinguishing between an actual right-hand-side assignment and the resulting value of an expression (where expression includes right-hand-side assignments :-).
Also, as far as I understand, right-hand-side assignment is still experimental (but maybe I got that wrong).
I think we should wait that RHS assignment is no longer experimental.
As I see it, it might get similar backlash as the pipeline operator and might still be removed (personally I don't like RHS assignment, I find it confusing and less readable).
Eregon (Benoit Daloze) wrote in #note-4:
I think we should wait that RHS assignment is no longer experimental.
As I see it, it might get similar backlash as the pipeline operator and might still be removed (personally I don't like RHS assignment, I find it confusing and less readable).
I agree and I’m not a big fan either. It seems to me that for some time there’s been accepting and immediately merging some changes that aren’t necessary instead of focusing on more important stuff.
Hope this is removed in the near future.
Oh okay, I thought it was a sure thing at this point - where is the experimental nature of it being tracked?
ioquatix (Samuel Williams) wrote in #note-6:
Oh okay, I thought it was a sure thing at this point - where is the experimental nature of it being tracked?
It's mentioned in NEWS.md. Both rightward assignment and endless method definition are currently considered experimental, and I think we shouldn't have any internal code or documentation use them until that is no longer the case.
- Status changed from Open to Closed
Okay great. For now, I'm satisfied we don't use this in documentation. However if we adopt it I'll consider it again.
- Related to Feature #15921: R-assign (rightward-assignment) operator added
I'm also not a big fan, but even if it becomes official it's not a good idea documentation-wise as it currently distinguishes cases where the return is self; there's no way to do this with the right assignment operator.
hsh.merge!(other_hash1, other_hash2, ...) -> hsh
(Oops, I thought this was a recent thread)
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0