[macruby-changes] [3674] MacRuby/branches/icu/string.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 2 18:45:54 PST 2010
Revision: 3674
http://trac.macosforge.org/projects/ruby/changeset/3674
Author: lsansonetti at apple.com
Date: 2010-03-02 18:45:54 -0800 (Tue, 02 Mar 2010)
Log Message:
-----------
added #chr
Modified Paths:
--------------
MacRuby/branches/icu/string.c
Modified: MacRuby/branches/icu/string.c
===================================================================
--- MacRuby/branches/icu/string.c 2010-03-03 02:42:32 UTC (rev 3673)
+++ MacRuby/branches/icu/string.c 2010-03-03 02:45:54 UTC (rev 3674)
@@ -2691,6 +2691,22 @@
/*
* call-seq:
+ * string.chr -> string
+ *
+ * Returns a one-character string at the beginning of the string.
+ *
+ * a = "abcde"
+ * a.chr #=> "a"
+ */
+
+static VALUE
+rstr_chr(VALUE str, SEL sel)
+{
+ return rstr_substr(str, 0, 1);
+}
+
+/*
+ * call-seq:
* str.to_f => float
*
* Returns the result of interpreting leading characters in <i>str</i> as a
@@ -4037,6 +4053,7 @@
rb_objc_define_method(rb_cRubyString, "hex", rstr_hex, 0);
rb_objc_define_method(rb_cRubyString, "oct", rstr_oct, 0);
rb_objc_define_method(rb_cRubyString, "ord", rstr_ord, 0);
+ rb_objc_define_method(rb_cRubyString, "chr", rstr_chr, 0);
rb_objc_define_method(rb_cRubyString, "to_f", rstr_to_f, 0);
rb_objc_define_method(rb_cRubyString, "chomp", rstr_chomp, -1);
rb_objc_define_method(rb_cRubyString, "chomp!", rstr_chomp_bang, -1);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100302/163846b2/attachment.html>
More information about the macruby-changes
mailing list