Live data from Hacker News

Ruby adds experimental support for rightward assignments

blog.saeloun.com

71–80 of 172 posts

Re: Ruby adds experimental support for rightward assignments

#71

>R language also has a similar way of doing this 42 -> age. Ah yes, the R language, a model of clarity, beauty and lightness in the world of programming languages. Truly an example to follow. (And it's not like anyone ever uses that "feature" in the R world either.)

shrug

I've used it. The overloading of the equals sign is something that has never made sense for assignment. (Seriously, it's hard to intentionally come up with dumber notation than x = x+1.) I do use -> sometimes. It's more natural to do the evaluation and then figure out where you're going to store the result (particularly when you're programming).

This is minor as these things go. Definitely not a big deal one way or the other.

Re: Ruby adds experimental support for rightward assignments

#74
post #53
post #39

Earlier quoted context omitted.

Not to me, and other people who use Ruby sparingly

I’m not sure. In shell, I think makejunk | grep foo | tail -4 > fourthings is more popular than > fourthings makejunk | grep foo | tail -4 Having said that, I don’t understand why you would add this, but then, I don’t understand the popularity of ruby or other languages that think adding alternative ways to do things most of the time is a good thing.

In shell outside of file manipulation,

  fourthings=$(makejunk | grep foo | tail -4)

Re: Ruby adds experimental support for rightward assignments

#79
post #24
post #4

Rightward assignment is pretty strongly discouraged in the R community, due to the effect it has of burying the lede. That said, I always felt the same about Ruby’s inline if/unless (`puts "still working" unless done`) so maybe it will have a better reception in this community.

Interesting, that it became discouraged. Probably won’t make it into Ruby proper then. I don’t fault them for experiment.

Actually, this is a pretty good reason, and it's straight from the source (creator of S, the predecessor of R): https://stackoverflow.com/a/51548423/139922

> When you type a long expression only to remember at the end that it would be a good idea to save the result, a right-hand arrow allows you to perform an assignment without retyping the line.

(I don't do this personally, though. I just run the expression and then my next command is `x <- .Last.value`)

Re: Ruby adds experimental support for rightward assignments

#80
post #2

[question]: Is the main benefit of "Rightward assignments" readability and does this provide more benefits?

I think I would use this if I were writing a cpu emulator in Ruby (which I wouldn't). It mirrors assembly, but I'm not sure that's a good thing.

It depends upon the assembly language. Intel defines its opcodes as `dest,src` and Motorola did `src,dest`.
Post reply on HN