Sure, but in Perl and other languages there is a difference between "$foo" and '$foo'. In that the first expands the value of foo, while the other doesn’t.
But usually if you need to write stuff in noisy strings, just use printf/sprintf. Or a <<HERE block.
I’m way happier debugging “200 char wide class name + 50 line of boilerplate” code written in java that verbosely and expressively does the same thing compared to deciphering single symbol hieroglyphs in shell esque scripts where I have to pay attention which way the ticks are pointing.
Does Ruby require the use of [] and {} there? Because those %w/%i/etc things look like custom quoting operators and at least in Perl you can use any delimiter you want: qw(a b c) is a list of strings, but so are qw+ab c+ and qw;ab c;.
Yes, very nice. But here comes the ugly;
[1,2,3].map(&:to_s)
oh ok, a bit hieroglyphic, but I can figure it out, seems like ‘&’ means element and ‘:’ means what I do with it.
files = `ls -1`
Aaah so a backtick is for strings? WRONG!!! IT EXECUTES THE FUCKING COMMAND!!!
ARGF.each { |line| puts line if /BEGIN/ .. /END/ }
What the hell is | and / ? Oh but I guess
..
is a range like in other languages, but what would be that range??? WRONG! I!!T’S A FLIP FLOP!!!%w{a b c} # array of strings %i[foo bar] # array of symbols %r{https?://\w+} # regex %x(ls -1) # run shell command
Ah, just memorize which letter to use by heart and that % is for type and that [ = { sometimes. But { unequal to { other times.
if line =~ /ERROR/ warn $~.post_match end
=~ neat!
$~ dafuq???
At this point I feel like ruby devs are just trolling us.
To be fair this is what they do in Perl and shell scripts (and in PHP too), so it’s not unexpected behavior in that world.
Yeah, you could very well argue that JS and others that use it for weird interpolated strings are the weird ones here.
On the other hand, interpolated strings are fucking awesome and you need them every 5 seconds for UI work
Sure, but in Perl and other languages there is a difference between
"$foo"
and'$foo'
. In that the first expands the value offoo
, while the other doesn’t.But usually if you need to write stuff in noisy strings, just use printf/sprintf. Or a <<HERE block.
I’m way happier debugging “200 char wide class name + 50 line of boilerplate” code written in java that verbosely and expressively does the same thing compared to deciphering single symbol hieroglyphs in shell esque scripts where I have to pay attention which way the ticks are pointing.
Does Ruby require the use of
[]
and{}
there? Because those%w
/%i
/etc things look like custom quoting operators and at least in Perl you can use any delimiter you want:qw(a b c)
is a list of strings, but so areqw+a b c+
andqw;a b c;
.Yes, but why?
https://en.wikipedia.org/wiki/Principle_of_least_astonishment