Re: Ruby stupidities



On 8/30/07, Kenneth McDonald <kenneth.m.mcdonald@xxxxxxxxxxxxx> wrote:
Having said that, here's my first entry. I think it's utterly stupid
(can you tell I just wasted some time tracking this down?) that

"abc"[0] == "a"

is false. Why doesn't that work? Because, with a single index, the array
access operator on a string returns, not the character at the given
position, but the _character code_ of the character at that position.

It would be useful if you actually looked what's happening in the
future: this will be changed for Ruby 1.9. It is, in fact, a sensible
choice to make given the nature of strings in Ruby.

-austin
--
Austin Ziegler * halostatue@xxxxxxxxx * http://www.halostatue.ca/
* austin@xxxxxxxxxxxxx * http://www.halostatue.ca/feed/
* austin@xxxxxxxxxxx

.



Relevant Pages

  • Re: ENTER character
    ... carriage return character, ASCII value 13, represented in a Ruby ... On *nix-variants, pressing the key ... Ruby string by "\n". ...
    (comp.lang.ruby)
  • Re: Question regarding design of the String Class
    ... string, ... > integer for the character at position i, exactly as in Ruby. ... I am not worried about the influence of other languages or trying to make Ruby like language X, I am trying to understand the logic behind some of the choices. ...
    (comp.lang.ruby)
  • Ruby stupidities
    ... However, any language has its unfortunate share of bad APIs, design decisions, etc., and Ruby is no exception. ... In order to keep this on a not-completely-shouting-match level, I think it's fair to give a reason something you mention as a Ruby Stupidity is in fact stupid. ... Because, with a single index, the array access operator on a string returns, not the character at the given position, but the _character code_ of the character at that position. ...
    (comp.lang.ruby)
  • Re: Why was the "Symbol is a String"-idea dropped?
    ... I want a Ruby that just works - crystal-clear, transparently, reliably. ... 10MB+1byte of binary dump, and the old 10MB object is garbage-collected. ... there are cases where it is just so *useful* to append to a string. ... because you'd have to look up the symbol ID to convert it into its character ...
    (comp.lang.ruby)
  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)