[#34722] cgi.rb の form の挙動 — FUJIOKA Takeyuki <fujioka@...>

藤岡です。

18 messages 2002/04/02

[#34724] 「たのしい Ruby 」 — Shin-ichiro HARA <sinara@...>

原(信)です。

18 messages 2002/04/02
[#34728] Re: 「たのしい Ruby 」 — matz@... (Yukihiro Matsumoto) 2002/04/02

まつもと ゆきひろです

[#34746] Re: 「たのしい Ruby 」 — TAKAHASHI Masayoshi <maki@...> 2002/04/02

高橋征義です。

[#34752] Re: 「たのしい Ruby 」 — Shin-ichiro HARA <sinara@...> 2002/04/03

原(信)です。

[#34842] [ann] Web 家計簿(β版)リリース — 堀川 久 <vzw00011@...>

こんにちは。

18 messages 2002/04/07
[#34869] Re: [ann] Web 家計簿(β版)リリース — Nobuhide Kanagawa <nobuhide@...> 2002/04/11

こんばんわ!

[#34885] creating a scope / anonymous module — Takaaki Tateishi <ttate@...>

立石です.

38 messages 2002/04/13
[#34891] Re: creating a scope / anonymous module — nobu.nakada@... 2002/04/14

なかだです。

[#34892] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/14

At Sun, 14 Apr 2002 18:00:12 +0900,

[#34894] Re: creating a scope / anonymous module — nobu.nakada@... 2002/04/14

なかだです。

[#34896] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/14

At Sun, 14 Apr 2002 21:08:47 +0900,

[#34899] Re: creating a scope / anonymous module — matz@... (Yukihiro Matsumoto) 2002/04/15

まつもと ゆきひろです

[#34901] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/15

At Mon, 15 Apr 2002 09:51:05 +0900,

[#34902] Re: creating a scope / anonymous module — matz@... (Yukihiro Matsumoto) 2002/04/15

まつもと ゆきひろです

[#34903] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/15

At Mon, 15 Apr 2002 13:53:53 +0900,

[#34904] Re: creating a scope / anonymous module — matz@... (Yukihiro Matsumoto) 2002/04/15

まつもと ゆきひろです

[#34910] Re: creating a scope / anonymous module — Takaaki Tateishi <ttate@...> 2002/04/15

At Mon, 15 Apr 2002 15:07:57 +0900,

[#34958] windows 版 ruby でシステムコマンドが動かない — "jazzski _comp" <jazzski_comp@...>

はじめてrubyを使うのですが、windows版(cygwin版1.6.1)で下記のように

12 messages 2002/04/23

[ruby-list:34840] Re: Array#select

From: Koji Arai <JCA02266@...>
Date: 2002-04-07 06:54:41 UTC
List: ruby-list #34840
新井です。

In message "[ruby-list:34839] Re: Array#select"
  on 07 Apr 2002 13:45:25 +0900,
  Koji Arai <JCA02266@nifty.ne.jp> wrote:
> 新井です。
> 
> In message "[ruby-list:34838] Array#select"
>   on 07 Apr 2002 13:24:58 +0900,
>   堀川 久 <vzw00011@nifty.ne.jp> wrote:
> > こんにちは。
> 
> > Arrayのサブクラスで事実上selectが使えませんが,どうしたらいいでしょう
> > か。

「どうしたらいいでしょうか?」を Array から Array2 のインス
タンスにする方法は?と考えると、Array#replace か、1.7 なら
Array.new を使うことになると思います。

で、ふと [ruby-dev:16773] 1.7 early access kit のことを考え
て以下のようにしてみました。変なバージョンチェック等の条件判
断はなしです。compat/ruby18.rb だかを require するという意図
は 1.6 での使用を前提としているとみなせますし、1.7 等でこれ
をやってもあまり問題は出ないからです。(条件判断を考えるのが
面倒臭かったとも言う^^;)

class Array
  alias orig_initialize initialize
  def initialize(size=0, val=nil)
    case size
    when Array
      self.replace(size)
      return
    when Fixnum
      if block_given?
	size.times {|i|
	  self.push yield(i)
	}
	return
      end
    end
    orig_initialize(size, val)
  end
end

require 'rubyunit'

class Array2 < Array
end

class SelTest < RUNIT::TestCase
  def test1
    ary = Array2.new
    assert_equal(Array2, ary.class)
    
    ary << 1 << 2 << 3
    assert_equal([1, 2, 3], ary)
    assert_equal(Array2, ary.class)

    ary = Array2.new(ary.select {|e| e % 2 == 1 ? true : false })
    assert_equal([1, 3], ary)
    assert_equal(Array2, ary.class)
  end
end

--
新井康司 (Koji Arai)

In This Thread