From: Julian Leviston Date: 2011-08-10T09:31:55+09:00 Subject: Re: *WHY* does this not work? c represents a temporary variable with a copy of the char in it. This is always the case. Use the map and join methods if you want to construct a new string in that manner, and then set the variable pointing to the old string to the new string. Blog: http://random8.zenunit.com/ Twitter: http://twitter.com/random8r Learn: http://sensei.zenunit.com/ New video up now at http://sensei.zenunit.com/ real fastcgi rails deploy process! Check it out now! On 10/08/2011, at 4:52 AM, serialhex wrote: > ok, so code: > > str = 'foo' > => "foo" > str.each_char do |c| > c = 'x' > end > => "foo" > > WHY does str == 'foo' still?? i would expect it to be 'xxx'! this makes no > sense, and is *QUITE* annoying... i end up having to do things like this: > > ... i CAN'T do things like that for a string because it dsn't seem to do > that, but for an array i'd have to: > > ary = ['f', 'o', 'o'] > => ["f", "o", "o"] > ary.each_index do |i| > ary[i] = 'x' > end > => ["x", "x", "x"] > > GAH!!! least surprise?? least surprise my FOOT!!! even if there was a > *.each! method to do that i would be fine, *that* would be ok, none of this > 'get the index and then do what you need to do and *THEN* set the stupid > block variable.... GRRRRRR!!!! > > /vent > hex > > -- > my blog is cooler than yours: serialhex.github.com > > The wise man said: "Never argue with an idiot. They bring you down to their > level and beat you with experience." > >>> Other than the fact Linux has a cool name, could someone explain why I >>> should use Linux over BSD? >> >> No. That's it. The cool name, that is. We worked very hard on >> creating a name that would appeal to the majority of people, and it >> certainly paid off: thousands of people are using linux just to be able >> to say "OS/2? Hah. I've got Linux. What a cool name". 386BSD made the >> mistake of putting a lot of numbers and weird abbreviations into the >> name, and is scaring away a lot of people just because it sounds too >> technical. > -- Linus Torvalds' follow-up to a question about Linux