I remember thinking it clashed a bit with the idea of trying to make the code read like natural language.
I remember thinking it clashed a bit with the idea of trying to make the code read like natural language.
It's an unusually half-baked feature by Ruby's standards. I think there was some hesitation about the name "it" initially, because "it" is an essential method name in rspec, and is used within blocks there.
I'd like know if `it` is merely an alias for `_1`, or if protects from this "arity issue" too.
pp open("|ls -lh /usr/bin/ls"){_1.read}
"-rwxr-xr-x 1 root root 135K Aug 30 04:57 /usr/bin/ls\n"
or to quickly print tabular data open("|column -t -s \\t", "w"){_1 << tsv_data}I use it for code like this:
raw = IO.popen(%W[gzip -d -c -- #{path}]){_1.read}
raw = IO.popen(%W[gzip -d -c], in: pipe){_1.read}
raw = IO.popen(%W[git status --porcelain -- #{path}]){_1.read}
Useful because it eliminates /bin/sh footguns (e.g. `md5sum hello&world` forking or `~john` expanding), plus you get kernel.spawn() options. `open("| ...)` only made sense for the second example.Anyway, I find "_1" more eye-pleasing than:
IO.popen(%W[gzip -d -c #{path}]){|io| io.read}The market for ruby seems to have good salaries and job satisfaction despite being smallish, so it didn't seem like a bad area to get some experience in.
Why, is there any issue with the choice I'm not aware of?
No, not at all. I was just interested since there is a sudden influx of people joining Ruby ( I guess mostly Rails ) companies without previous Ruby background. As I have notice this across HN, Reddit, Twitter and elsewhere. And yes Ruby market tends to be on the slightly higher end because they mostly hire people with years of programming experiences and lack of junior position. And there used to be complains about not being able to find people with Ruby / Rails experiences etc. So it is a good market shift I guess.
There is a niche there of very popular channels producing Ruby tutorials, seemingly aimed at the junior js-bootcamp dev crowd. They also focus on Neovim, tmux and other terminal based tools.
It is a completely anecdotal observation, but my guess is that it might explain part of the trend.