[#41918] [Feature #3647] Array#sample(n, replace=false) — Kenta Murata <redmine@...>
Feature #3647: Array#sample(n, replace=false)
チケット #3647 が更新されました。 (by Masaya Tarui)
まつもと ゆきひろです
[#41925] Ruby committers Q&A at RubyKaigi — Shugo Maeda <shugo@...>
前田です。
2010/8/3 Shugo Maeda <shugo@ruby-lang.org>:
前田です。
[#41931] [Bug #3657] make cleanがファイルを削除しすぎ — Takahiro Kambe <redmine@...>
Bug #3657: make cleanがファイルを削除しすぎ
[#41933] *array で異常終了 — 小田 利通 <oda@...>
[#41957] 1.9.2でtest_require_too_long_filename(TestRequire)がFailureになる — kimura wataru <kimuraw@...>
木村(わ)といいます。
[#41962] Re: [ruby-cvs:36129] Ruby:r28927 (ruby_1_9_2): merges r28835 from trunk into ruby_1_9_2. — Masaki Suketa <masaki.suketa@...>
助田です。
[#41966] [Bug #3673] PTY.getpty with IO.pipe doesn't finish on FreeBSD — Yui NARUSE <redmine@...>
Bug #3673: PTY.getpty with IO.pipe doesn't finish on FreeBSD
2010年8月10日10:53 Yui NARUSE <redmine@ruby-lang.org>:
[#41969] [Feature #3675] String#prepend, String#>> — Sora Harakami <redmine@...>
Feature #3675: String#prepend, String#>>
まつもと ゆきひろです
[#41971] Re: [ruby-cvs:36152] Ruby:r28950 (trunk): [ruby-core:31658] — "NARUSE, Yui" <naruse@...>
成瀬です。
> なお、unused variable で警告するのはおかしいという主張もありえるでしょう。
[#41972] [Bug #3676] CMath.cbrt(-8)の結果が複素数にならない — tadayoshi funaba <redmine@...>
Bug #3676: CMath.cbrt(-8)の結果が複素数にならない
まつもと ゆきひろです
> 現在のCMath.cbrt(-8)の結果は-2で、これは3乗すると-8になるとい
[#41974] Re: [ruby-cvs:36157] Ruby:r28955 (trunk): * complex.c (nucomp_to_[ifr]): don't allow complex with in-exact — Yukihiro Matsumoto <matz@...>
まつもと ゆきひろです
> これを戻されたということは、(1+0.0i)は整数に変換できてはいけ
まつもと ゆきひろです
> なるほど。動機は分かりました。ただ、今回の変更はいずれも明示
まつもと ゆきひろです
[#41995] Re: [ruby-core:31672] [Bug #3678] CMath.sqrt(1.i) results to 0.0+0.0i — Urabe Shyouhei <shyouhei@...>
-devに振ります。
[#42003] WEBrickに関するセキュリティ修正 (CVE-2010-0541) — Hideki Yamane <henrich@...>
2010/8/11 Hideki Yamane <henrich@debian.or.jp>:
こんにちは、なかむら(う)です。
2010/8/12 U.Nakamura <usa@garbagecollect.jp>:
こんにちは、なかむら(う)です。
2010/8/12 U.Nakamura <usa@garbagecollect.jp>:
[#42022] [Bug #3693] visibility hidden functions — Narihiro Nakamura <redmine@...>
Bug #3693: visibility hidden functions
ささだです.
[#42038] [Bug: trunk] Fwd: [ruby-list:47272] case when 整数と実数の比較 (ruby 1.9) — SASADA Koichi <ko1@...>
ささだです.
[#42040] [Bug #3674] dRuby サーバプロセスを停止する時に時間がかかることがある — Tomoyuki Chikanaga <redmine@...>
チケット #3674 が更新されました。 (by Tomoyuki Chikanaga)
遠藤です。
[#42057] rdf generated by rss library is not valid — Tanaka Akira <akr@...>
ふと、rss ライブラリのチュートリアルの
[#42067] [Bug #3708] Array#permutation がおかしな結果を返す — Shumpei Akai <redmine@...>
Bug #3708: Array#permutation がおかしな結果を返す
[#42079] Re: [ruby-cvs:36248] Ruby:r29048 (trunk): * backport r28621 and r28632 from ruby_1_8; — "NARUSE, Yui" <naruse@...>
このコミットで OpenSSL のテスト失敗が増えています。
2010/8/19 NARUSE, Yui <naruse@airemix.jp>:
2010/8/19 Hiroshi Nakamura <nakahiro@gmail.com>:
(2010/08/19 18:58), Hiroshi Nakamura wrote:
[#42090] Math::atan2(0, 0) on ruby 1.9.2 — KUBO Takehiro <kubo@...>
久保です。
=1B$B$`$i$?$G$9!#=1B(B
遠藤です。
久保です。
=1B$B$`$i$?$G$9!#=1B(B
[#42093] version.hのRUBY_VERSION_TEENYが古いのでは? — Moru <lateau@...>
44KC44KL44Go55Sz44GX44G+44GZ44CCCgokIGhlYWQgcnVieS0xLjkuMi1wMC92ZXJzaW9uLmgK
[#42100] make distclean時エラーメッセージ — Moru <lateau@...>
=E3=82=82=E3=82=8B=E3=81=A7=E3=81=99=E3=80=82
[#42125] vc9 x64でtrunk dlがコンパイルできない — kuwamoto shintaro <beuniv@...>
こんにちわ
[#42166] Ruby'sライセンスの、BSDLとのデュアルライセンスへの変更 — "NARUSE, Yui" <naruse@...>
Ruby's ライセンスは BSDL と Ruby's のデュアルライセンスになります。
(2010/09/01 1:48), NARUSE, Yui wrote:
[ruby-dev:41969] [Feature #3675] String#prepend, String#>>
Feature #3675: String#prepend, String#>>
http://redmine.ruby-lang.org/issues/show/3675
起票者: Sora Harakami
ステータス: Open, 優先度: Normal
sorahです.
通常, Stringでの文字列を手前に破壊的に加えるのは, a = "foo" + a 等で行いますが,
直感で読みにくく, 記号などで書きにくくなっていると思います.
なので, String#prependと String#>> を追加するというのはどうでしょうか.
それぞれ以下のように機能します.
a = "bar"
a.prepend("foo") #=> "foobar"
p a #=> "foobar"
b = "bar"
"foo" >> b #=> "foobar"
p b #=> "foobar"
patchはこちらです (git diff --no-prefixにて生成):
diff --git string.c string.c
index 0aa2e6c..6c9be57 100644
--- string.c
+++ string.c
@@ -2055,6 +2055,43 @@ rb_str_concat(VALUE str1, VALUE str2)
}
}
+/*
+ * call-seq:
+ * str.prepend(other_str) -> str
+ *
+ * Prepend---Prepend the given string to <i>str</i>.
+ *
+ * a = "world"
+ * a.prepend("hello ") #=> "hello world"
+ * a #=> "hello world"
+ */
+
+static VALUE
+rb_str_prepend(VALUE str, VALUE str2)
+{
+ StringValue(str2);
+ StringValue(str);
+ rb_str_update(str, 0L, 0L, str2);
+ return str;
+}
+
+/*
+ * call-seq:
+ * str >> other_str -> other_str
+ *
+ * Prepend---Prepend self string to <i>other_str</i>.
+ *
+ * a = "world"
+ * "hello " >> a #=> "hello world"
+ * a #=> "hello world"
+ */
+
+static VALUE
+rb_str_prepend_to_another(VALUE str1, VALUE str2)
+{
+ return rb_str_prepend(str2, str1);
+}
+
st_index_t
rb_memhash(const void *ptr, long len)
{
@@ -7524,6 +7561,8 @@ Init_String(void)
rb_define_method(rb_cString, "reverse!", rb_str_reverse_bang, 0);
rb_define_method(rb_cString, "concat", rb_str_concat, 1);
rb_define_method(rb_cString, "<<", rb_str_concat, 1);
+ rb_define_method(rb_cString, "prepend", rb_str_prepend, 1);
+ rb_define_method(rb_cString, ">>", rb_str_prepend_to_another, 1);
rb_define_method(rb_cString, "crypt", rb_str_crypt, 1);
rb_define_method(rb_cString, "intern", rb_str_intern, 0);
rb_define_method(rb_cString, "to_sym", rb_str_intern, 0);
diff --git test/ruby/test_string.rb test/ruby/test_string.rb
index 02271ce..da2477f 100644
--- test/ruby/test_string.rb
+++ test/ruby/test_string.rb
@@ -1882,4 +1882,36 @@ class TestString < Test::Unit::TestCase
assert_equal('"\\u3042\\u3044\\u3046"', "\u3042\u3044\u3046".encode(e).inspect)
end
end
+
+ def test_prepend_to_another
+ assert_equal(S("hello world"), "hello " >> "world")
+
+ foo = Object.new
+ def foo.to_str
+ "b"
+ end
+ assert_equal(S("ab"), "a" >> foo)
+
+ a = S("world!")
+ b = S("hello ")
+ b >> a
+ assert_equal(S("hello world!"), a)
+ assert_equal(S("hello "), b)
+ end
+
+ def test_prepend
+ assert_equal(S("hello world!"), "world!".prepend("hello "))
+
+ foo = Object.new
+ def foo.to_str
+ "b"
+ end
+ assert_equal(S("ba"), "a".prepend(foo))
+
+ a = S("world")
+ b = S("hello ")
+ a.prepend(b)
+ assert_equal(S("hello world"), a)
+ assert_equal(S("hello "), b)
+ end
end
----------------------------------------
http://redmine.ruby-lang.org