Project

General

Profile

Actions

Misc #16802

closed

Prefer use of RHS assigment in documentation

Added by ioquatix (Samuel Williams) almost 4 years ago. Updated almost 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.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #15921: R-assign (rightward-assignment) operatorClosedmatz (Yukihiro Matsumoto)Actions

Updated by ioquatix (Samuel Williams) almost 4 years ago

  • Assignee set to ioquatix (Samuel Williams)

Updated by ioquatix (Samuel Williams) almost 4 years ago

@matz (Yukihiro Matsumoto) do you mind letting me know your thoughts?

Updated by duerst (Martin Dürst) almost 4 years ago

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).

Updated by Eregon (Benoit Daloze) almost 4 years ago

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).

Updated by greggzst (Grzegorz Jakubiak) almost 4 years ago

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.

Updated by ioquatix (Samuel Williams) almost 4 years ago

Oh okay, I thought it was a sure thing at this point - where is the experimental nature of it being tracked?

Updated by jeremyevans0 (Jeremy Evans) almost 4 years ago

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.

Updated by ioquatix (Samuel Williams) almost 4 years ago

  • 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.

Actions #9

Updated by Eregon (Benoit Daloze) almost 4 years ago

  • Related to Feature #15921: R-assign (rightward-assignment) operator added

Updated by marcandre (Marc-Andre Lafortune) almost 4 years ago

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)

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0