Project

General

Profile

Actions

Bug #4126

closed

Pathname#+ サブクラスの場合

Added by shyouhei (Shyouhei Urabe) over 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Target version:
ruby -v:
ruby 1.9.3dev (2010-12-06 trunk 30091) [x86_64-linux]
Backport:
[ruby-dev:42693]

Description

=begin
Pathnameを継承したときにいくつかのメソッドが自身のクラスのインスタンスを生成すべきだというpull requestが来ています。ご判断下さい。

https://github.com/shyouhei/ruby/pull/2
=end

Actions #1

Updated by akr (Akira Tanaka) about 13 years ago

=begin
2010年12月6日21:07 Shyouhei Urabe :

Pathnameを継承したときにいくつかのメソッドが自身のクラスのインスタンスを生成すべきだというpull requestが来ています。ご判断下さい。

考えたのですが、

class A < Array
end
p((A.new + A.new).class)

が A でなく Array になるのと同様、
とりあえず Pathname でも

class P < Pathname
end
p((P.new(".") + P.new(".")).class)
p((P.new(".").relative_path_from(P.new("."))).class)

は P でなく Pathname でいいんじゃないかと思います。

どちらも Pathname ふたつからひとつ作るので、
レシーバのクラスを使うのが自明に正しいとはいえないでしょう。

[田中 哲][たなか あきら][Tanaka Akira]

=end

Updated by ko1 (Koichi Sasada) almost 13 years ago

  • Status changed from Assigned to Rejected
Actions

Also available in: Atom PDF

Like0
Like0Like0