From: Szabolcs Szasz Date: 2002-10-20T05:01:13+09:00 Subject: Re: string[lastchar] -> string? -- ehh, OK, I shut up for today... (OK, I'm doing great today... _Of course_ the String class doesn't have str() method... Er.., I was just asking it for a friend of mine... ;-) ) Sab ----- Original Message ----- From: "Szabolcs Szasz" To: "ruby-talk ML" Sent: Saturday, October 19, 2002 9:55 PM Subject: Re: string[lastchar] -> string? > Ahhh, yes! Thanks! > > I was reading the Pragmatic... book and the String class > doesn't have that 'chr' method there. (And a special thanks > for the negative indexes, which I missed completely...) > > Thanks again, > Sab > > ----- Original Message ----- > From: "Ibraheem Ibz Umaru-Mohammed" > To: "ruby-talk ML" > Sent: Saturday, October 19, 2002 9:48 PM > Subject: Re: string[lastchar] -> string? > > > > * Szabolcs Szasz [2002-10-19 20:33]: > > > How to elegantly get the last char of a string as a string? > > > Somehow I fear I won't be cacthing girls' attention with this: > > > > > > if ('' << str[str.length-1]) = 'x' > > > str.chop > > > do_things_with(str) > > > ... > > > end > > > > > > > ibz@ignoramus:$ irb > > Reading config file... done. > > ruby-1.7.3 on i686-pc-linux with irb 0.9(02/07/03) > > Type 'help' for more information. > > >>> str = "This is a string" > > "This is a string" > > >>> str[-1].chr > > "g" > > >>> > > > > Is that what you are looking for? > > > > --ibz. > > -- > > > > > > >