--1926193751-1951042972-1187008779=:9230
Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-1951042972-1187008779=:9230"
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--1926193751-1951042972-1187008779=:9230
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE
Hi --
Hi,
Am Montag, 13. Aug 2007, 15:15:54 +0900 schrieb Stephan K=E4mper:
Am 13.08.2007 um 08:04 schrieb Bertram Scharpf:
Well, here's something that should be a little bit less cycle intensive
(depending on how String#[](arg) is implemented):
class String
def last
self[-1].chr
end
end
This is what I would have implemented, too.
The difficult point is that it raises some questions:
- Should it return a Fixnum or a String of lenght 1?
If it ever gets added to Ruby, it will presumably be in 1.9/2.0, where
str[x] gives you a character anyway. If it doesn't get added, then
everyone will write their own, hopefully in a safe way, and can do
whatever they like
- Should it be able to return UTF-8 characters?
- Should I define String#shift and String#pop now?
There's already #chop. I don't know whether there are plans for
#lchop or equivalent.
David
--=20
* Books:
RAILS ROUTING (new!
http://www.awprofessional.com/title/0321509242)
RUBY FOR RAILS (
http://www.manning.com/black)
* Ruby/Rails training
& consulting: Ruby Power and Light, LLC (
http://www.rubypal.com)
--1926193751-1951042972-1187008779=:9230--
--1926193751-1951042972-1187008779=:9230--