From d2cede86e5f79b6f12be192d52d5f92f3a359964 Mon Sep 17 00:00:00 2001 From: Josh Fenio Date: Mon, 8 Dec 2014 21:10:39 -0700 Subject: [PATCH] add missing documentation around String#chomp This commit adds documentation around the behavior of String#chomp when passed an empty string (a string with a length of zero). --- string.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/string.c b/string.c index 95c773b..4d82d9b 100644 --- a/string.c +++ b/string.c @@ -7161,15 +7161,18 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str) * from the end of str (if present). If $/ has not been * changed from the default Ruby record separator, then chomp also * removes carriage return characters (that is it will remove \n, - * \r, and \r\n). - * - * "hello".chomp #=> "hello" - * "hello\n".chomp #=> "hello" - * "hello\r\n".chomp #=> "hello" - * "hello\n\r".chomp #=> "hello\n" - * "hello\r".chomp #=> "hello" - * "hello \n there".chomp #=> "hello \n there" - * "hello".chomp("llo") #=> "he" + * \r, and \r\n). If $/ is an empty string, + * it will remove all trailing newlines from the string. + * + * "hello".chomp #=> "hello" + * "hello\n".chomp #=> "hello" + * "hello\r\n".chomp #=> "hello" + * "hello\n\r".chomp #=> "hello\n" + * "hello\r".chomp #=> "hello" + * "hello \n there".chomp #=> "hello \n there" + * "hello".chomp("llo") #=> "he" + * "hello\r\n\r\n".chomp('') #=> "hello" + * "hello\r\n\r\r\n".chomp('') #=> "hello\r\n\r" */ static VALUE