|
[ruby-list:42475] String#first, String#last: msg#00129lang.ruby.japanese
こんにちは。柳田です。 String の先頭/末尾 n バイトを得るのに、 Array と同じく first last が使えると便利だと思いました。 もちろん、 class String def first(n) self[0, n] end def last(n) self[[size - n, 0].max, n] end end と自分で定義してもよいのですが、 標準で提供されていると便利ではないかと思います。 というわけで String#first と String#last を提案してみたいのですが、 いかがでしょうか。 -- Kouhei Yanagita <yanagi at shakenbu.org>
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [ruby-list:42474] Re: 多量の正規表現との効率的なマッチのアイデアを、、, Itou-T15-l4TFbgTioCUTBYAz+LHnZg |
|---|---|
| Next by Date: | [ruby-list:42476] Gtk::FileSelection の filename=, Takeshi Honda |
| Previous by Thread: | [ruby-list:42466] Affordable medicine directly fr0m manufacturer, Lucy |
| Next by Thread: | [ruby-list:42482] Re: String#first, String#last, Yukihiro Matsumoto |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |