News for hackers. Stuff that matters.
Re:Ruby One-Liners by asicsp on Saturday September 14, 2019 @12:24AM (#20968894)
I made a compilation of Ruby one-liners [1] as well last year.

There's plenty of stuff that is similar to Perl, which in turn had borrowed from awk, sed and other tools. The biggest difference I'd pick is Perl's context based operation.

    # Ruby requires explicit conversion with to_i
    ruby -ane 'print if $F[1].to_i > 35'
    perl -ane 'print if $F[1] > 35'
Performance is slower compared to Perl, but to those who already know Ruby, this would suit better than learning the nuances of another language.

[1] https://github.com/learnbyexample/Command-line-text-processi...

Re:Ruby One-Liners by pizza234 on Saturday September 14, 2019 @03:28AM (#20969433)
There are other significant other functionalities that I find very handy in oneliners, notably:

- automatic associative array instantiation

- the return value of regular expressions with a capture group is the value matched by it (in Ruby, the closest to this is `[/regex/, <group_i>]`)

Re:Ruby One-Liners by Maledictus on Saturday September 14, 2019 @02:26AM (#20969267)
I can't stand weak types, so I prefer Ruby even if it is a little longer. Thanks for pointing this out.