3 ms·
> It seems like a waste of precious syntax to dedicate backticks to running shell commands. Except from Bash (where backticks also have the same purpose as Rub
by lucasoshiro 2y ago
> It seems like a waste of precious syntax to dedicate backticks to running shell commands.
Except from Bash (where backticks also have the same purpose as Ruby), I only remember seeing backticks in:
- Kotlin, for naming functions with phrases. The only use case that I remember for it was to creating more meaningful names for test functions. I don't think that it was so useful...
- Lisp dialects for quasiquotes, which is meaningless in Ruby
- Haskell, for making functions infix, and I can't see why would it be useful in Ruby (Ruby has it own way to make infix methods)
- JS, for creating templates. In Ruby we can use double quotes for that
> "thou shalt not parse the output of 'ls'"
Yes, but it was only an example of associating backticks and the language features. Of course it is not ideal, but it is an example that everyone will understand. You'll probably won't want to use it (even because you can do it with Dir.glob('*').map { |f| f.length }).
The same happened later in the text when I used a regex to find the Git branch.
> You really want to read the directory and map over the stat function (or equivalent) to get the length.
But that is not Ruby.