From: Gavin Sinclair Date: 2002-10-12T04:11:32+09:00 Subject: Re: syntax string[0]=?t From: "Kontra, Gergely" > Hi! > > Is there any good idea how should a character represented in ruby? The > current one looks weird an is not intuitive, and more and more such > things are inserted into ruby (@@var as a class variable eg.) , so it > begins to look like a perl program (and one character change -> another > program ) :-/ Well, you know about "if str[0] == ?M", obviously. What's wrong with that? OK, it's not intuitive, but it's easy to learn and harmless. I like it, actually. Like so much else in Ruby, it economises typing without sacrificing readability. ?c Ruby 'c' Most other languages That's a 33% saving in screen real estate for the reasonably common operation of specifying a specific individual character. > BTW is there any possibility to write blocks like we can write > for i in [1,2,5,2,6,1,6] > puts i > end > > But that time the each iterator is called, if I'm right. > Can I use it with other procedures accepting a block? No, only each. I really like the "for a in x" syntax, but then when you make a minor variation and have to use "each_with_index" instead of the implicit "each", the code looks inconsistent, so most of the time I use explicit "each" now. > Gergo Gavin