Closed MichaelHoste closed 3 years ago
Thanks!
Just one quick question: how does Ruby behave with the ternary operator? Like PHP or like C (see https://github.com/php-gettext/Languages#parenthesis-in-ternary-operators)?
If it behaves like C, we could suggest users to use --parenthesis=no
for Ruby in the readme.
For example, without the --parenthesis
flag (or with --parenthesis=yes
) we have:
'iu' => {
'name' => 'Inuktitut',
'formula' => '(n == 1) ? 0 : ((n == 2) ? 1 : 2)',
With --parenthesis=no
:
'iu' => {
'name' => 'Inuktitut',
'formula' => 'n == 1 ? 0 : n == 2 ? 1 : 2',
Just one quick question: how does Ruby behave with the ternary operator? Like PHP or like C (see https://github.com/php-gettext/Languages#parenthesis-in-ternary-operators)?
It behaves like C, so the --parenthesis=no
would make sense for shorter syntax. But both options would work, right?
Yep, both would work, but removing unneeded parenthesis makes the code a bit more readable (I do hate that PHP behavior with ternary operator, and I'm not the only one). See 4ad818b
I agree this is more readable once you're used to it!
I understand your hate of the PHP ternary operator, it's absolutely counter-intuitive and your example on the README was really surprising to me. It's a good thing it's deprecated on PHP 7 and triggers a fatal error on PHP 8 (cf. https://3v4l.org/QAAnA)
Export a
.rb
file that can be easily imported in your Ruby application.if you feel that it can be used by someone else than me 😉