From 1034068ce02abf5ba176be4ca055cfb70bbd4d52 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Wed, 4 Jul 2012 14:03:12 -0700 Subject: [PATCH] Improve documentation for String Add example for String#bytesize Add example for String#empty? Add example for String#* Add example for String#dump Update doc for String#center --- string.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/string.c b/string.c index e275e577ea601e..ce1f456a4407cf 100644 --- a/string.c +++ b/string.c @@ -1148,6 +1148,9 @@ rb_str_length(VALUE str) * str.bytesize -> integer * * Returns the length of str in bytes. + * + * "\x80\u3042".bytesize #=> 4 + * "hello".bytesize #=> 5 */ static VALUE @@ -1163,6 +1166,7 @@ rb_str_bytesize(VALUE str) * Returns true if str has a length of zero. * * "hello".empty? #=> false + * " ".empty? #=> false * "".empty? #=> true */ @@ -1210,9 +1214,10 @@ rb_str_plus(VALUE str1, VALUE str2) * str * integer -> new_str * * Copy---Returns a new String containing integer copies of - * the receiver. + * the receiver. integer must be greater than or equal to 0. * * "Ho! " * 3 #=> "Ho! Ho! Ho! " + * "Ho! " * 0 #=> "" */ VALUE @@ -4534,6 +4539,8 @@ rb_str_inspect(VALUE str) * * Produces a version of str with all nonprinting characters replaced by * \nnn notation and all special characters escaped. + * + * "hello \n ''".dump #=> "\"hello \\n ''\" */ VALUE @@ -7126,7 +7133,7 @@ rb_str_rjust(int argc, VALUE *argv, VALUE str) /* * call-seq: - * str.center(integer, padstr) -> new_str + * str.center(integer, padstr='') -> new_str * * If integer is greater than the length of str, returns a new * String of length integer with str centered and