From: Bertram Scharpf Date: 2007-08-13T15:04:28+09:00 Subject: Re: first and last char Hi, Am Sonntag, 12. Aug 2007, 02:43:00 +0900 schrieb Felix Windt: > > -----Original Message----- > > From: botp [mailto:botpena@gmail.com] > > Sent: Saturday, August 11, 2007 10:30 AM > > > > wish there were #first and #last in String > > irb(main):001:0> class String > irb(main):002:1> def first > irb(main):003:2> self.split('').first > irb(main):004:2> end > irb(main):005:1> def last > irb(main):006:2> self.split('').last > irb(main):007:2> end > irb(main):008:1> end > => nil > irb(main):009:0> "testing".first > => "t" > irb(main):010:0> "testing".last > => "g" Sometimes I wish every young programmer was forced to do a month in Assembler and another one in C just to see what cost in time and space some constructions cause. Sorry, Felix! Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de