[#15625] rb_hash_initialize — Takaaki Tateishi <ttate@...>

立石です.

22 messages 2002/01/04
[#15627] Re: rb_hash_initialize — matz@... (Yukihiro Matsumoto) 2002/01/04

まつもと ゆきひろです

[#15628] Re: rb_hash_initialize — Takaaki Tateishi <ttate@...> 2002/01/04

立石です.

[#15685] undefined method `inherited' for false (NameError) — WATANABE Hirofumi <eban@...>

わたなべです。

13 messages 2002/01/15
[#15686] Re: undefined method `inherited' for false (NameError) — nobu.nakada@... 2002/01/15

なかだです。

[#15757] 文字列→整数変換 — nobu.nakada@...

なかだです。

30 messages 2002/01/25

[#15830] [ 提案 ] puts, print 等を IO から分離 — UENO Katsuhiro <unnie@...>

うえのです。

14 messages 2002/01/31

[ruby-dev:15677] Module#<=>

From: Koji Arai <JCA02266@...>
Date: 2002-01-12 06:03:01 UTC
List: ruby-dev #15677
新井です。

親子関係にないクラス同士の比較で

	p Class.new <=> Class.new
	=> ruby 1.7.2 (2002-01-05) [i586-linux]
	   1

は、常に 1 です。他の不等号演算子では、常に false です。

	p Class.new < Class.new
	p Class.new > Class.new
	=> ruby 1.7.2 (2002-01-05) [i586-linux]
	   false
	   false

これは、仕様でしょうか?マニュアルにどう書くべきか迷っています。

| --- self <=> other
| 
|     (({self})) と (({other})) を比較して、
|     (({self})) が (({other})) の子孫であるとき -1、
|     同一のクラス/モジュールのとき 0、
|     (({self})) が (({other})) の先祖であるとき 1
| 
|     を返します。
|     親子関係にないクラス同士の比較ではその動作は不定です
|     ((-あらい 2002-01-12: たぶん。仕様上不定。実装では特定といったところ-))。
| 
| 	  module Foo
| 	  end
| 	  class Bar
| 	    include Foo
| 	  end
| 	  class Baz < Bar
| 	  end
| 	  class Qux
| 	  end
| 	  p Bar <=> Foo     # => -1
| 	  p Baz <=> Bar     # => -1
| 	  p Baz <=> Foo     # => -1
| 	  p Baz <=> Qux     # => 1
| 	  p Qux <=> Baz     # => 1
| 
| --- self < other
| --- self <= other
| --- self > other
| --- self >= other
| 
|     比較演算子。(({self})) が ((|other|)) の子孫である時、
|     (({self < other})) が成立します。
| 
|     親子関係にないクラス同士の比較ではいずれの関係も false を返します。
| 
| 	  module Foo
| 	  end
| 	  class Bar
| 	    include Foo
| 	  end
| 	  class Baz < Bar
| 	  end
| 	  class Qux
| 	  end
| 	  p Bar < Foo     # => foo
| 	  p Baz < Bar     # => foo
| 	  p Baz < Foo     # => foo
| 	  p Baz < Qux     # => false
| 	  p Baz > Qux     # => false

--
新井康司 (Koji Arai)

In This Thread

Prev Next