From e7b7a10fe37d85a5063e1655f0b82e66125a93ca Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 26 Feb 2008 18:38:15 +0000 Subject: fixed #562 --- src/library/scala/runtime/RichString.scala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index 435422bb64..de6e4bdbd9 100644 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -138,11 +138,14 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char linesWithSeparators map (line => new RichString(line).stripLineEnd) /** Returns this string with first character converted to upper case */ - def capitalize: String = { - val chars = self.toCharArray - chars(0) = chars(0).toUpperCase - new String(chars) - } + def capitalize: String = + if (self == null) null + else if (self.length == 0) "" + else { + val chars = self.toCharArray + chars(0) = chars(0).toUpperCase + new String(chars) + } /**

* For every line in this string: -- cgit v1.2.3