Project

General

Profile

Misc #16802

Prefer use of RHS assigment in documentation

Added by ioquatix (Samuel Williams) 5 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
[ruby-core:97989]

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

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

Updated by ioquatix (Samuel Williams) 5 months ago

  • Assignee set to ioquatix (Samuel Williams)

Updated by ioquatix (Samuel Williams) 5 months ago

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

Updated by duerst (Martin Dürst) 5 months 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) 5 months 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) 5 months 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) 5 months 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) 5 months 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) 5 months 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.

#9

Updated by Eregon (Benoit Daloze) 5 months ago

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

Updated by marcandre (Marc-Andre Lafortune) 4 months 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)

Also available in: Atom PDF