[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24181: 25.1.50; ruby mode: wrong auto indent after "?" string litera
From: |
Ryo Furue |
Subject: |
bug#24181: 25.1.50; ruby mode: wrong auto indent after "?" string literal |
Date: |
Thu, 11 Aug 2016 15:41:35 +0900 |
Hi,
> Thanks for the report. I'd like to fix it sometime, but it's not a big
> priority, considering this syntax is usually discouraged:
>
> https://github.com/bbatsov/ruby-style-guide#no-character-literals
Thank you for the link! It seems very comprehensive and must be useful
for many other issues, too.
I agree the bug I reported isn't a big issue.
>> ?a is a valid Ruby syntax for string literal. After writing this, I
>> learned
>> that "a".ord is equivalent (I think)
>
> Yes, in Ruby 1.9 and newer, it's a full equivalent.
After my last message, I learned that Ruby has abandoned the idea of
"character type" and instead of elevating ?a to a proper character
literal, it has made it equivalent to a single-character string "a".
So, a String is no longer a sequence of individual characters (because
"character" has no representation in the language). "a".ord returns
the character code of this single-character string but "abc".ord
ignores the "bc" part. I don't think that's a clean design, but
perhaps it's the simplest, practical one, in the face of various
character encodings. . . . That makes me wonder how Haskell handles
unicode. In that language, "String" is an alias for "[Char]" (list
of Char's). . . . I digressed.
Cheers,
Ryo